import%20marimo%0A%0A__generated_with%20%3D%20%220.12.4%22%0Aapp%20%3D%20marimo.App(%0A%20%20%20%20width%3D%22full%22%2C%0A%20%20%20%20layout_file%3D%22data%3Aapplication%2Fjson%3Bbase64%2CewogICJ0eXBlIjogInNsaWRlcyIsCiAgImRhdGEiOiB7fQp9%22%2C%0A)%0A%0A%0A%40app.cell%0Adef%20_()%3A%0A%20%20%20%20%23%20Import%20all%20the%20required%20libraries%0A%20%20%20%20import%20functools%0A%20%20%20%20import%20re%0A%20%20%20%20from%20operator%20import%20itemgetter%0A%0A%20%20%20%20import%20marimo%20as%20mo%0A%20%20%20%20import%20matplotlib.pyplot%20as%20plt%0A%20%20%20%20import%20numpy%20as%20np%0A%20%20%20%20import%20pandas%20as%20pd%0A%20%20%20%20import%20seaborn%20as%20sb%0A%20%20%20%20from%20matplotlib.ticker%20import%20StrMethodFormatter%0A%20%20%20%20from%20sklearn.ensemble%20import%20ExtraTreesRegressor%2C%20RandomForestRegressor%0A%20%20%20%20from%20sklearn.experimental%20import%20enable_iterative_imputer%0A%20%20%20%20from%20sklearn.gaussian_process%20import%20GaussianProcessRegressor%0A%20%20%20%20from%20sklearn.impute%20import%20IterativeImputer%0A%20%20%20%20from%20sklearn.isotonic%20import%20IsotonicRegression%0A%20%20%20%20from%20sklearn.linear_model%20import%20(%0A%20%20%20%20%20%20%20%20BayesianRidge%2C%0A%20%20%20%20%20%20%20%20ElasticNet%2C%0A%20%20%20%20%20%20%20%20HuberRegressor%2C%0A%20%20%20%20%20%20%20%20Lasso%2C%0A%20%20%20%20%20%20%20%20LinearRegression%2C%0A%20%20%20%20%20%20%20%20RANSACRegressor%2C%0A%20%20%20%20%20%20%20%20Ridge%2C%0A%20%20%20%20%20%20%20%20SGDRegressor%2C%0A%20%20%20%20)%0A%20%20%20%20from%20sklearn.metrics%20import%20mean_squared_error%2C%20r2_score%0A%20%20%20%20from%20sklearn.neighbors%20import%20KNeighborsRegressor%0A%20%20%20%20from%20sklearn.pipeline%20import%20make_pipeline%0A%20%20%20%20from%20sklearn.preprocessing%20import%20PolynomialFeatures%0A%20%20%20%20from%20sklearn.svm%20import%20SVR%2C%20LinearSVR%0A%20%20%20%20from%20sklearn.tree%20import%20DecisionTreeRegressor%0A%0A%20%20%20%20%23%20Set%20the%20seaborn%20style%0A%20%20%20%20sb.set_theme()%0A%20%20%20%20return%20(%0A%20%20%20%20%20%20%20%20BayesianRidge%2C%0A%20%20%20%20%20%20%20%20DecisionTreeRegressor%2C%0A%20%20%20%20%20%20%20%20ElasticNet%2C%0A%20%20%20%20%20%20%20%20ExtraTreesRegressor%2C%0A%20%20%20%20%20%20%20%20GaussianProcessRegressor%2C%0A%20%20%20%20%20%20%20%20HuberRegressor%2C%0A%20%20%20%20%20%20%20%20IsotonicRegression%2C%0A%20%20%20%20%20%20%20%20IterativeImputer%2C%0A%20%20%20%20%20%20%20%20KNeighborsRegressor%2C%0A%20%20%20%20%20%20%20%20Lasso%2C%0A%20%20%20%20%20%20%20%20LinearRegression%2C%0A%20%20%20%20%20%20%20%20LinearSVR%2C%0A%20%20%20%20%20%20%20%20PolynomialFeatures%2C%0A%20%20%20%20%20%20%20%20RANSACRegressor%2C%0A%20%20%20%20%20%20%20%20RandomForestRegressor%2C%0A%20%20%20%20%20%20%20%20Ridge%2C%0A%20%20%20%20%20%20%20%20SGDRegressor%2C%0A%20%20%20%20%20%20%20%20SVR%2C%0A%20%20%20%20%20%20%20%20StrMethodFormatter%2C%0A%20%20%20%20%20%20%20%20enable_iterative_imputer%2C%0A%20%20%20%20%20%20%20%20functools%2C%0A%20%20%20%20%20%20%20%20itemgetter%2C%0A%20%20%20%20%20%20%20%20make_pipeline%2C%0A%20%20%20%20%20%20%20%20mean_squared_error%2C%0A%20%20%20%20%20%20%20%20mo%2C%0A%20%20%20%20%20%20%20%20np%2C%0A%20%20%20%20%20%20%20%20pd%2C%0A%20%20%20%20%20%20%20%20plt%2C%0A%20%20%20%20%20%20%20%20r2_score%2C%0A%20%20%20%20%20%20%20%20re%2C%0A%20%20%20%20%20%20%20%20sb%2C%0A%20%20%20%20)%0A%0A%0A%40app.cell%0Adef%20_(np)%3A%0A%20%20%20%20%23%20The%20constants%20used%20in%20the%20program%0A%0A%20%20%20%20%23%20The%20path%20to%20the%20data%20file%0A%20%20%20%20DATA_FILE%20%3D%20%22.%2Fdata.xls%22%0A%0A%20%20%20%20%23%20The%20minimum%20and%20maximum%20values%20for%20the%20multiplier%0A%20%20%20%20MULTIPLIER_MAX_VALUE%20%3D%20100%0A%20%20%20%20MULTIPLIER_MIN_VALUE%20%3D%20-100%0A%0A%20%20%20%20%23%20The%20list%20of%20columns%20to%20drop%0A%20%20%20%20COLUMNS_TO_DROP%20%3D%20%5B%0A%20%20%20%20%20%20%20%20%23%20Drop%20the%20country%20code%20as%20we%20are%20using%20the%20country%20name%0A%20%20%20%20%20%20%20%20%22Country%20code%22%2C%0A%20%20%20%20%20%20%20%20%23%20These%20two%20columns%20below%20are%20useless%0A%20%20%20%20%20%20%20%20%22SCALE%22%2C%0A%20%20%20%20%20%20%20%20%22Decimals%22%2C%0A%20%20%20%20%20%20%20%20%23%20There%20is%20no%20data%20for%202011%2C%20so%20just%20drop%20it%0A%20%20%20%20%20%20%20%20%222011%22%2C%0A%20%20%20%20%5D%0A%0A%20%20%20%20%23%20The%20list%20of%20series%20codes%20for%20problem%201%0A%20%20%20%20SERIES_CODES_PROBLEM_1%20%3D%20%5B%0A%20%20%20%20%20%20%20%20%23%20CO2%20emissions%20per%20capita%20(metric%20tons)%0A%20%20%20%20%20%20%20%20%22EN.ATM.CO2E.PC%22%2C%0A%20%20%20%20%20%20%20%20%23%20CO2%20emissions%20per%20units%20of%20GDP%20(kg%2F%241%2C000%20of%202005%20PPP%20%24)%0A%20%20%20%20%20%20%20%20%22EN.ATM.CO2E.PP.GD.KD%22%2C%0A%20%20%20%20%20%20%20%20%23%20CO2%20emissions%2C%20total%20(KtCO2)%0A%20%20%20%20%20%20%20%20%22EN.ATM.CO2E.KT%22%2C%0A%20%20%20%20%20%20%20%20%23%20Methane%20(CH4)%20emissions%2C%20total%20(KtCO2e)%0A%20%20%20%20%20%20%20%20%22EN.ATM.METH.KT.CE%22%2C%0A%20%20%20%20%20%20%20%20%23%20Nitrous%20oxide%20(N2O)%20emissions%2C%20total%20(KtCO2e)%0A%20%20%20%20%20%20%20%20%22EN.ATM.NOXE.KT.CE%22%2C%0A%20%20%20%20%20%20%20%20%23%20Other%20GHG%20emissions%2C%20total%20(KtCO2e)%0A%20%20%20%20%20%20%20%20%22EN.ATM.GHGO.KT.CE%22%2C%0A%20%20%20%20%20%20%20%20%23%20Energy%20use%20per%20capita%20(kilograms%20of%20oil%20equivalent)%0A%20%20%20%20%20%20%20%20%22EG.USE.PCAP.KG.OE%22%2C%0A%20%20%20%20%20%20%20%20%23%20Energy%20use%20per%20units%20of%20GDP%20(kg%20oil%20eq.%2F%241%2C000%20of%202005%20PPP%20%24)%0A%20%20%20%20%20%20%20%20%22EG.USE.COMM.GD.PP.KD%22%2C%0A%20%20%20%20%5D%0A%0A%20%20%20%20%23%20The%20map%20of%20the%20series%20code%20to%20its%20multiplier%20for%20problem%202%0A%20%20%20%20SERIES_CODE_TO_MULTIPLIER_MAP%20%3D%20%7B%0A%20%20%20%20%20%20%20%20%23%20Access%20to%20improved%20sanitation%20(%25%20of%20total%20pop.)%0A%20%20%20%20%20%20%20%20%22SH.STA.ACSN%22%3A%201%2C%0A%20%20%20%20%20%20%20%20%23%20Access%20to%20improved%20water%20source%20(%25%20of%20total%20pop.)%0A%20%20%20%20%20%20%20%20%22SH.H2O.SAFE.ZS%22%3A%201%2C%0A%20%20%20%20%20%20%20%20%23%20CO2%20emissions%20per%20capita%20(metric%20tons)%0A%20%20%20%20%20%20%20%20%22EN.ATM.CO2E.PC%22%3A%20-1%2C%0A%20%20%20%20%20%20%20%20%23%20CO2%20emissions%20per%20units%20of%20GDP%20(kg%2F%241%2C000%20of%202005%20PPP%20%24)%0A%20%20%20%20%20%20%20%20%22EN.ATM.CO2E.PP.GD.KD%22%3A%20-1%2C%0A%20%20%20%20%20%20%20%20%23%20CO2%20emissions%2C%20total%20(KtCO2)%0A%20%20%20%20%20%20%20%20%22EN.ATM.CO2E.KT%22%3A%20-1%2C%0A%20%20%20%20%20%20%20%20%23%20Cereal%20yield%20(kg%20per%20hectare)%0A%20%20%20%20%20%20%20%20%22AG.YLD.CREL.KG%22%3A%201%2C%0A%20%20%20%20%20%20%20%20%23%20Foreign%20direct%20investment%2C%20net%20inflows%20(%25%20of%20GDP)%0A%20%20%20%20%20%20%20%20%22BX.KLT.DINV.WD.GD.ZS%22%3A%201%2C%0A%20%20%20%20%20%20%20%20%23%20GDP%20(%24)%0A%20%20%20%20%20%20%20%20%22NY.GDP.MKTP.CD%22%3A%201%2C%0A%20%20%20%20%20%20%20%20%23%20GNI%20per%20capita%20(Atlas%20%24)%0A%20%20%20%20%20%20%20%20%22NY.GNP.PCAP.CD%22%3A%201%2C%0A%20%20%20%20%20%20%20%20%23%20Nationally%20terrestrial%20protected%20areas%20(%25%20of%20total%20land%20area)%0A%20%20%20%20%20%20%20%20%22ER.LND.PTLD.ZS%22%3A%201%2C%0A%20%20%20%20%20%20%20%20%23%20Paved%20roads%20(%25%20of%20total%20roads)%0A%20%20%20%20%20%20%20%20%22IS.ROD.PAVE.ZS%22%3A%201%2C%0A%20%20%20%20%20%20%20%20%23%20Physicians%20(per%201%2C000%20people)%0A%20%20%20%20%20%20%20%20%22SH.MED.PHYS.ZS%22%3A%201%2C%0A%20%20%20%20%20%20%20%20%23%20Under-five%20mortality%20rate%20(per%201%2C000)%0A%20%20%20%20%20%20%20%20%22SH.DYN.MORT%22%3A%20-1%2C%0A%20%20%20%20%20%20%20%20%23%20Energy%20use%20per%20capita%20(kilograms%20of%20oil%20equivalent)%0A%20%20%20%20%20%20%20%20%22EG.USE.PCAP.KG.OE%22%3A%20-1%2C%0A%20%20%20%20%20%20%20%20%23%20Energy%20use%20per%20units%20of%20GDP%20(kg%20oil%20eq.%2F%241%2C000%20of%202005%20PPP%20%24)%0A%20%20%20%20%20%20%20%20%22EG.USE.COMM.GD.PP.KD%22%3A%20-1%2C%0A%20%20%20%20%20%20%20%20%23%20Methane%20(CH4)%20emissions%2C%20total%20(KtCO2e)%0A%20%20%20%20%20%20%20%20%22EN.ATM.METH.KT.CE%22%3A%20-1%2C%0A%20%20%20%20%20%20%20%20%23%20Nitrous%20oxide%20(N2O)%20emissions%2C%20total%20(KtCO2e)%0A%20%20%20%20%20%20%20%20%22EN.ATM.NOXE.KT.CE%22%3A%20-1%2C%0A%20%20%20%20%20%20%20%20%23%20Other%20GHG%20emissions%2C%20total%20(KtCO2e)%0A%20%20%20%20%20%20%20%20%22EN.ATM.GHGO.KT.CE%22%3A%20-1%2C%0A%20%20%20%20%7D%0A%0A%20%20%20%20%23%20The%20list%20of%20all%20the%20series%20codes%20needed%0A%20%20%20%20SERIES_CODES%20%3D%20%5B%0A%20%20%20%20%20%20%20%20%23%0A%20%20%20%20%20%20%20%20%23%20Mostly%20complete%20data%0A%20%20%20%20%20%20%20%20%23%0A%20%20%20%20%20%20%20%20%23%20Cereal%20yield%20(kg%20per%20hectare)%0A%20%20%20%20%20%20%20%20%22AG.YLD.CREL.KG%22%2C%0A%20%20%20%20%20%20%20%20%23%20Foreign%20direct%20investment%2C%20net%20inflows%20(%25%20of%20GDP)%0A%20%20%20%20%20%20%20%20%22BX.KLT.DINV.WD.GD.ZS%22%2C%0A%20%20%20%20%20%20%20%20%23%20Energy%20use%20per%20units%20of%20GDP%20(kg%20oil%20eq.%2F%241%2C000%20of%202005%20PPP%20%24)%0A%20%20%20%20%20%20%20%20%22EG.USE.COMM.GD.PP.KD%22%2C%0A%20%20%20%20%20%20%20%20%23%20Energy%20use%20per%20capita%20(kilograms%20of%20oil%20equivalent)%0A%20%20%20%20%20%20%20%20%22EG.USE.PCAP.KG.OE%22%2C%0A%20%20%20%20%20%20%20%20%23%20CO2%20emissions%2C%20total%20(KtCO2)%0A%20%20%20%20%20%20%20%20%22EN.ATM.CO2E.KT%22%2C%0A%20%20%20%20%20%20%20%20%23%20CO2%20emissions%20per%20capita%20(metric%20tons)%0A%20%20%20%20%20%20%20%20%22EN.ATM.CO2E.PC%22%2C%0A%20%20%20%20%20%20%20%20%23%20CO2%20emissions%20per%20units%20of%20GDP%20(kg%2F%241%2C000%20of%202005%20PPP%20%24)%0A%20%20%20%20%20%20%20%20%22EN.ATM.CO2E.PP.GD.KD%22%2C%0A%20%20%20%20%20%20%20%20%23%20Nationally%20terrestrial%20protected%20areas%20(%25%20of%20total%20land%20area)%0A%20%20%20%20%20%20%20%20%22ER.LND.PTLD.ZS%22%2C%0A%20%20%20%20%20%20%20%20%23%20GDP%20(%24)%0A%20%20%20%20%20%20%20%20%22NY.GDP.MKTP.CD%22%2C%0A%20%20%20%20%20%20%20%20%23%20GNI%20per%20capita%20(Atlas%20%24)%0A%20%20%20%20%20%20%20%20%22NY.GNP.PCAP.CD%22%2C%0A%20%20%20%20%20%20%20%20%23%20Under-five%20mortality%20rate%20(per%201%2C000)%0A%20%20%20%20%20%20%20%20%22SH.DYN.MORT%22%2C%0A%20%20%20%20%20%20%20%20%23%20Population%20growth%20(annual%20%25)%0A%20%20%20%20%20%20%20%20%22SP.POP.GROW%22%2C%0A%20%20%20%20%20%20%20%20%23%20Population%0A%20%20%20%20%20%20%20%20%22SP.POP.TOTL%22%2C%0A%20%20%20%20%20%20%20%20%23%20Urban%20population%20growth%20(annual%20%25)%0A%20%20%20%20%20%20%20%20%22SP.URB.GROW%22%2C%0A%20%20%20%20%20%20%20%20%23%20Urban%20population%0A%20%20%20%20%20%20%20%20%22SP.URB.TOTL%22%2C%0A%20%20%20%20%20%20%20%20%23%0A%20%20%20%20%20%20%20%20%23%20Spotty%20data%0A%20%20%20%20%20%20%20%20%23%0A%20%20%20%20%20%20%20%20%23%20Population%20in%20urban%20agglomerations%20%3E1million%20(%25)%0A%20%20%20%20%20%20%20%20%22EN.URB.MCTY.TL.ZS%22%2C%0A%20%20%20%20%20%20%20%20%23%20Paved%20roads%20(%25%20of%20total%20roads)%0A%20%20%20%20%20%20%20%20%22IS.ROD.PAVE.ZS%22%2C%0A%20%20%20%20%20%20%20%20%23%20Ratio%20of%20girls%20to%20boys%20in%20primary%20%26%20secondary%20school%20(%25)%0A%20%20%20%20%20%20%20%20%22SE.ENR.PRSC.FM.ZS%22%2C%0A%20%20%20%20%20%20%20%20%23%20Primary%20completion%20rate%2C%20total%20(%25%20of%20relevant%20age%20group)%0A%20%20%20%20%20%20%20%20%22SE.PRM.CMPT.ZS%22%2C%0A%20%20%20%20%20%20%20%20%23%20Physicians%20(per%201%2C000%20people)%0A%20%20%20%20%20%20%20%20%22SH.MED.PHYS.ZS%22%2C%0A%20%20%20%20%20%20%20%20%23%0A%20%20%20%20%20%20%20%20%23%20Data%20every%205%20years%20from%201990%20-%202005%0A%20%20%20%20%20%20%20%20%23%0A%20%20%20%20%20%20%20%20%23%20Other%20GHG%20emissions%2C%20total%20(KtCO2e)%0A%20%20%20%20%20%20%20%20%22EN.ATM.GHGO.KT.CE%22%2C%0A%20%20%20%20%20%20%20%20%23%20Methane%20(CH4)%20emissions%2C%20total%20(KtCO2e)%0A%20%20%20%20%20%20%20%20%22EN.ATM.METH.KT.CE%22%2C%0A%20%20%20%20%20%20%20%20%23%20Nitrous%20oxide%20(N2O)%20emissions%2C%20total%20(KtCO2e)%0A%20%20%20%20%20%20%20%20%22EN.ATM.NOXE.KT.CE%22%2C%0A%20%20%20%20%20%20%20%20%23%0A%20%20%20%20%20%20%20%20%23%20Data%20every%205%20years%20from%201990%20-%202005%20plus%202008%0A%20%20%20%20%20%20%20%20%23%0A%20%20%20%20%20%20%20%20%23%20Access%20to%20improved%20water%20source%20(%25%20of%20total%20pop.)%0A%20%20%20%20%20%20%20%20%22SH.H2O.SAFE.ZS%22%2C%0A%20%20%20%20%20%20%20%20%23%20Access%20to%20improved%20sanitation%20(%25%20of%20total%20pop.)%0A%20%20%20%20%20%20%20%20%22SH.STA.ACSN%22%2C%0A%20%20%20%20%5D%0A%0A%20%20%20%20%23%20The%20list%20of%20regions%20for%20problem%201%0A%20%20%20%20REGIONS_FOR_PROBLEM_1%20%3D%20%5B%0A%20%20%20%20%20%20%20%20%22World%22%2C%0A%20%20%20%20%20%20%20%20%22Europe%20%26%20Central%20Asia%22%2C%0A%20%20%20%20%20%20%20%20%22Latin%20America%20%26%20Caribbean%22%2C%0A%20%20%20%20%20%20%20%20%22East%20Asia%20%26%20Pacific%22%2C%0A%20%20%20%20%20%20%20%20%22Middle%20East%20%26%20North%20Africa%22%2C%0A%20%20%20%20%20%20%20%20%22South%20Asia%22%2C%0A%20%20%20%20%20%20%20%20%22Sub-Saharan%20Africa%22%2C%0A%20%20%20%20%20%20%20%20%22Euro%20area%22%2C%0A%20%20%20%20%20%20%20%20%22Small%20island%20developing%20states%22%2C%0A%20%20%20%20%5D%0A%0A%20%20%20%20%23%20The%20list%20of%20regions%20to%20remove%20for%20problem%202%0A%20%20%20%20REGIONS_TO_REMOVE_FOR_PROBLEM_2%20%3D%20%5B%0A%20%20%20%20%20%20%20%20%22East%20Asia%20%26%20Pacific%22%2C%0A%20%20%20%20%20%20%20%20%22Europe%20%26%20Central%20Asia%22%2C%0A%20%20%20%20%20%20%20%20%22Euro%20area%22%2C%0A%20%20%20%20%20%20%20%20%22High%20income%22%2C%0A%20%20%20%20%20%20%20%20%22Latin%20America%20%26%20Caribbean%22%2C%0A%20%20%20%20%20%20%20%20%22Low%20income%22%2C%0A%20%20%20%20%20%20%20%20%22Lower%20middle%20income%22%2C%0A%20%20%20%20%20%20%20%20%22Low%20%26%20middle%20income%22%2C%0A%20%20%20%20%20%20%20%20%22Middle%20income%22%2C%0A%20%20%20%20%20%20%20%20%22Middle%20East%20%26%20North%20Africa%22%2C%0A%20%20%20%20%20%20%20%20%22South%20Asia%22%2C%0A%20%20%20%20%20%20%20%20%22Sub-Saharan%20Africa%22%2C%0A%20%20%20%20%20%20%20%20%22Upper%20middle%20income%22%2C%0A%20%20%20%20%20%20%20%20%22Small%20island%20developing%20states%22%2C%0A%20%20%20%20%20%20%20%20%22World%22%2C%0A%20%20%20%20%5D%0A%0A%20%20%20%20%23%20The%20range%20of%20years%20in%20the%20data%20set.%0A%20%20%20%20%23%0A%20%20%20%20%23%20There%20is%20no%20data%20for%202011%2C%20so%20we%20are%20skipping%20it%0A%20%20%20%20YEAR_RANGE%20%3D%20np.array(list(range(1990%2C%202010%20%2B%201)))%0A%0A%20%20%20%20%23%20The%20year%20range%20as%20a%20string%20for%20easier%20indexing%20into%20the%20data%20frame%0A%20%20%20%20YEAR_RANGE_STR%20%3D%20%5Bstr(year)%20for%20year%20in%20YEAR_RANGE%5D%0A%20%20%20%20return%20(%0A%20%20%20%20%20%20%20%20COLUMNS_TO_DROP%2C%0A%20%20%20%20%20%20%20%20DATA_FILE%2C%0A%20%20%20%20%20%20%20%20MULTIPLIER_MAX_VALUE%2C%0A%20%20%20%20%20%20%20%20MULTIPLIER_MIN_VALUE%2C%0A%20%20%20%20%20%20%20%20REGIONS_FOR_PROBLEM_1%2C%0A%20%20%20%20%20%20%20%20REGIONS_TO_REMOVE_FOR_PROBLEM_2%2C%0A%20%20%20%20%20%20%20%20SERIES_CODES%2C%0A%20%20%20%20%20%20%20%20SERIES_CODES_PROBLEM_1%2C%0A%20%20%20%20%20%20%20%20SERIES_CODE_TO_MULTIPLIER_MAP%2C%0A%20%20%20%20%20%20%20%20YEAR_RANGE%2C%0A%20%20%20%20%20%20%20%20YEAR_RANGE_STR%2C%0A%20%20%20%20)%0A%0A%0A%40app.cell%0Adef%20_()%3A%0A%20%20%20%20%23%20Constants%20used%20for%20the%20UI%0A%0A%20%20%20%20%23%20The%20table%20page%20size%20to%20use%0A%20%20%20%20TABLE_PAGE_SIZE%20%3D%2020%0A%0A%20%20%20%20%23%20The%20hex%20code%20for%20the%20green%20colour%0A%20%20%20%20GREEN_COLOUR%20%3D%20%22%233CB034%22%0A%20%20%20%20return%20GREEN_COLOUR%2C%20TABLE_PAGE_SIZE%0A%0A%0A%40app.cell%0Adef%20_(TABLE_PAGE_SIZE%2C%20functools%2C%20mo)%3A%0A%20%20%20%20def%20html(*args)%3A%0A%20%20%20%20%20%20%20%20%22Function%20to%20more%20easily%20write%20HTML.%22%0A%20%20%20%20%20%20%20%20return%20mo.Html(%0A%20%20%20%20%20%20%20%20%20%20%20%20%22%5Cn%22.join(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5Barg%20if%20isinstance(arg%2C%20str)%20else%20arg.text%20for%20arg%20in%20args%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20def%20md(*args)%3A%0A%20%20%20%20%20%20%20%20%22Function%20to%20more%20easily%20write%20markdown.%22%0A%20%20%20%20%20%20%20%20return%20mo.md(%0A%20%20%20%20%20%20%20%20%20%20%20%20%22%5Cn%22.join(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5Barg%20if%20isinstance(arg%2C%20str)%20else%20arg.text%20for%20arg%20in%20args%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20%23%20The%20function%20to%20create%20a%20Marimo%20table%20UI%0A%20%20%20%20%23%20with%20the%20default%20arguments%20passed%20so%20we%0A%20%20%20%20%23%20don't%20have%20to%20keep%20writing%20the%20same%20things%0A%20%20%20%20%23%20over%20and%20over%20again%0A%20%20%20%20ui_table%20%3D%20functools.partial(%0A%20%20%20%20%20%20%20%20mo.ui.table%2C%20selection%3DNone%2C%20page_size%3DTABLE_PAGE_SIZE%0A%20%20%20%20)%0A%0A%20%20%20%20def%20html_heading(heading_level%3A%20int%2C%20heading%3A%20str)%3A%0A%20%20%20%20%20%20%20%20%22Function%20to%20more%20easily%20create%20a%20HTML%20heading.%22%0A%20%20%20%20%20%20%20%20return%20html(f%22%3Ch%7Bheading_level%7D%3E%22%2C%20heading%2C%20f%22%3C%2Fh%7Bheading_level%7D%3E%22)%0A%0A%20%20%20%20def%20md_heading(heading_level%3A%20int%2C%20heading%3A%20str)%3A%0A%20%20%20%20%20%20%20%20%22Function%20to%20more%20easily%20create%20a%20markdown%20heading.%22%0A%20%20%20%20%20%20%20%20return%20md(f%22%7B'%23'%20*%20heading_level%7D%20%7Bheading%7D%22)%0A%0A%20%20%20%20def%20html_hyperlink(string%3A%20str%2C%20link%3A%20str)%3A%0A%20%20%20%20%20%20%20%20%22Function%20to%20more%20easily%20create%20a%20HTML%20hyperlink.%22%0A%20%20%20%20%20%20%20%20return%20html(f%22%3Ca%20href%3D%7Blink%7D%3E%7Bstring%7D%3C%2Fa%3E%22)%0A%0A%20%20%20%20def%20md_hyperlink(string%3A%20str%2C%20link%3A%20str)%3A%0A%20%20%20%20%20%20%20%20%22Function%20to%20more%20easily%20create%20a%20markdown%20hyperlink.%22%0A%20%20%20%20%20%20%20%20return%20md(f%22%5B%7Bstring%7D%5D(%7Blink%7D)%22)%0A%0A%20%20%20%20def%20style_inline(string%3A%20str%2C%20**styles%3A%20str)%3A%0A%20%20%20%20%20%20%20%20%22%22%22%0A%20%20%20%20%20%20%20%20Function%20to%20style%20a%20string%20with%20inline%20styles.%0A%0A%20%20%20%20%20%20%20%20The%20first%20argument%20is%20the%20string%20to%20style%20with%20an%0A%20%20%20%20%20%20%20%20inline%20span%20element%2C%20and%20the%20keyword%20arguments%0A%20%20%20%20%20%20%20%20are%20the%20CSS%20styles%0A%20%20%20%20%20%20%20%20%22%22%22%0A%0A%20%20%20%20%20%20%20%20%23%20Create%20the%20style%20string%20for%20the%20element%0A%20%20%20%20%20%20%20%20style_string%20%3D%20%22%2C%20%22.join(%0A%20%20%20%20%20%20%20%20%20%20%20%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20f%22%7Bkey.replace('_'%2C%20'-')%7D%3A%20%7Bvalue%7D%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20for%20key%2C%20value%20in%20styles.items()%0A%20%20%20%20%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20return%20html(f%22%3Cspan%20style%3D'%7Bstyle_string%7D'%3E%7Bstring%7D%3C%2Fspan%3E%22)%0A%0A%20%20%20%20def%20html_list(list_type%3A%20str%2C%20*elements)%3A%0A%20%20%20%20%20%20%20%20%22%22%22%0A%20%20%20%20%20%20%20%20Function%20to%20create%20HTML%20lists%20more%20easily.%0A%0A%20%20%20%20%20%20%20%20The%20list%20type%20can%20either%20by%20an%20ordered%20list%20(ol)%2C%0A%20%20%20%20%20%20%20%20or%20an%20unordered%20list%20(ul).%0A%20%20%20%20%20%20%20%20%22%22%22%0A%20%20%20%20%20%20%20%20return%20html(%0A%20%20%20%20%20%20%20%20%20%20%20%20f%22%3C%7Blist_type%7D%3E%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20*%5Bf%22%3Cli%3E%7Belement%7D%3C%2Fli%3E%22%20for%20element%20in%20elements%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20f%22%3C%2F%7Blist_type%7D%3E%22%2C%0A%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20def%20html_ordered_list(*elements)%3A%0A%20%20%20%20%20%20%20%20%22Function%20to%20create%20a%20HTML%20ordered%20list%20more%20easily.%22%0A%20%20%20%20%20%20%20%20return%20html_list(%22ol%22%2C%20*elements)%0A%0A%20%20%20%20def%20html_numbered_list(*elements)%3A%0A%20%20%20%20%20%20%20%20%22%22%22%0A%20%20%20%20%20%20%20%20Function%20to%20create%20a%20numbered%20HTML%20list%20more%20easily.%0A%0A%20%20%20%20%20%20%20%20This%20function%20is%20an%20alias%20for%20the%20html_ordered_list%20function.%0A%20%20%20%20%20%20%20%20%22%22%22%0A%20%20%20%20%20%20%20%20return%20html_ordered_list(*elements)%0A%0A%20%20%20%20def%20html_unordered_list(*elements)%3A%0A%20%20%20%20%20%20%20%20%22Function%20to%20create%20a%20HTML%20unordered%20list%20more%20easily.%22%0A%20%20%20%20%20%20%20%20return%20html_list(%22ul%22%2C%20*elements)%0A%0A%20%20%20%20def%20html_unnumbered_list(*elements)%3A%0A%20%20%20%20%20%20%20%20%22%22%22%0A%20%20%20%20%20%20%20%20Function%20to%20create%20a%20HTML%20list%20without%20numbering%20more%20easily.%0A%0A%20%20%20%20%20%20%20%20This%20function%20is%20an%20alias%20for%20the%20html_unordered_list%20function.%0A%20%20%20%20%20%20%20%20%22%22%22%0A%20%20%20%20%20%20%20%20return%20html_ordered_list(*elements)%0A%0A%20%20%20%20def%20html_element(element_type%3A%20str%2C%20*elements)%3A%0A%20%20%20%20%20%20%20%20%22Function%20to%20more%20easily%20create%20HTML%20elements.%22%0A%20%20%20%20%20%20%20%20return%20html(f%22%3C%7Belement_type%7D%3E%22%2C%20*elements%2C%20f%22%3C%2F%7Belement_type%7D%3E%22)%0A%0A%20%20%20%20def%20md_ordered_list(*elements)%3A%0A%20%20%20%20%20%20%20%20%22Function%20to%20create%20a%20markdown%20ordered%20list%20more%20easily.%22%0A%20%20%20%20%20%20%20%20return%20md(%0A%20%20%20%20%20%20%20%20%20%20%20%20*%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20f%22%7Bindex%7D.%20%7Belement%7D%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20for%20index%2C%20element%20in%20enumerate(elements%2C%20start%3D1)%0A%20%20%20%20%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20def%20md_numbered_list(*elements)%3A%0A%20%20%20%20%20%20%20%20%22%22%22%0A%20%20%20%20%20%20%20%20Function%20to%20create%20a%20numbered%20markdown%20list%20more%20easily.%0A%0A%20%20%20%20%20%20%20%20This%20function%20is%20an%20alias%20for%20the%20md_ordered_list%20function.%0A%20%20%20%20%20%20%20%20%22%22%22%0A%20%20%20%20%20%20%20%20return%20md_ordered_list(*elements)%0A%0A%20%20%20%20def%20md_unordered_list(*elements)%3A%0A%20%20%20%20%20%20%20%20%22Function%20to%20create%20a%20markdown%20unordered%20list%20more%20easily.%22%0A%20%20%20%20%20%20%20%20return%20md(*%5Bf%22-%20%7Belement%7D%22%20for%20element%20in%20elements%5D)%0A%0A%20%20%20%20def%20md_unnumbered_list(*elements)%3A%0A%20%20%20%20%20%20%20%20%22%22%22%0A%20%20%20%20%20%20%20%20Function%20to%20create%20a%20markdown%20list%20without%20numbering%20more%20easily.%0A%0A%20%20%20%20%20%20%20%20This%20function%20is%20an%20alias%20for%20the%20md_unordered_list%20function.%0A%20%20%20%20%20%20%20%20%22%22%22%0A%20%20%20%20%20%20%20%20return%20md_unordered_list(*elements)%0A%0A%20%20%20%20def%20centred_slide_title(title%3A%20str)%3A%0A%20%20%20%20%20%20%20%20%22Function%20to%20return%20a%20centred%20slide%20title.%22%0A%20%20%20%20%20%20%20%20return%20md(f%22%23%23%20%7Btitle%7D%22).center().style(padding_bottom%3D%2220px%22)%0A%20%20%20%20return%20(%0A%20%20%20%20%20%20%20%20centred_slide_title%2C%0A%20%20%20%20%20%20%20%20html%2C%0A%20%20%20%20%20%20%20%20html_element%2C%0A%20%20%20%20%20%20%20%20html_heading%2C%0A%20%20%20%20%20%20%20%20html_hyperlink%2C%0A%20%20%20%20%20%20%20%20html_list%2C%0A%20%20%20%20%20%20%20%20html_numbered_list%2C%0A%20%20%20%20%20%20%20%20html_ordered_list%2C%0A%20%20%20%20%20%20%20%20html_unnumbered_list%2C%0A%20%20%20%20%20%20%20%20html_unordered_list%2C%0A%20%20%20%20%20%20%20%20md%2C%0A%20%20%20%20%20%20%20%20md_heading%2C%0A%20%20%20%20%20%20%20%20md_hyperlink%2C%0A%20%20%20%20%20%20%20%20md_numbered_list%2C%0A%20%20%20%20%20%20%20%20md_ordered_list%2C%0A%20%20%20%20%20%20%20%20md_unnumbered_list%2C%0A%20%20%20%20%20%20%20%20md_unordered_list%2C%0A%20%20%20%20%20%20%20%20style_inline%2C%0A%20%20%20%20%20%20%20%20ui_table%2C%0A%20%20%20%20)%0A%0A%0A%40app.cell%0Adef%20_(GREEN_COLOUR%2C%20html%2C%20style_inline)%3A%0A%20%20%20%20%23%20Constants%20used%20in%20the%20slides%0A%0A%20%20%20%20%23%20The%20question%20for%20problem%201%0A%20%20%20%20PROBLEM_1_QUESTION%20%3D%20html(%0A%20%20%20%20%20%20%20%20f%22Are%20we%20getting%20%7Bstyle_inline('greener'%2C%20color%3DGREEN_COLOUR)%7D%22%2C%0A%20%20%20%20%20%20%20%20f%22or%20%7Bstyle_inline('more%20sustainable'%2C%20color%3DGREEN_COLOUR)%7D%3F%22%2C%0A%20%20%20%20)%0A%0A%20%20%20%20%23%20The%20question%20for%20problem%202%0A%20%20%20%20PROBLEM_2_QUESTION%20%3D%20html(%22Which%20country%20should%20I%20move%20to%20in%20the%20future%3F%22)%0A%20%20%20%20return%20PROBLEM_1_QUESTION%2C%20PROBLEM_2_QUESTION%0A%0A%0A%40app.cell%0Adef%20_(DATA_FILE%2C%20pd)%3A%0A%20%20%20%20%23%20Read%20the%20data%20from%20the%20data%20file%0A%20%20%20%20climate_change_excel_sheet%20%3D%20pd.read_excel(DATA_FILE%2C%20sheet_name%3DNone)%0A%0A%20%20%20%20%23%20Get%20the%20data%20from%20the%20excel%20sheet%0A%20%20%20%20data%20%3D%20climate_change_excel_sheet%5B%22Data%22%5D%0A%20%20%20%20series_descriptions%20%3D%20climate_change_excel_sheet%5B%22Series%22%5D%0A%0A%20%20%20%20%23%20Convert%20all%20the%20column%20names%20to%20string%0A%20%20%20%20data.columns%20%3D%20data.columns.astype(str)%0A%20%20%20%20return%20climate_change_excel_sheet%2C%20data%2C%20series_descriptions%0A%0A%0A%40app.cell%0Adef%20_(series_descriptions)%3A%0A%20%20%20%20%23%20Create%20the%20map%20from%20the%20series%20code%20to%20the%20series%20name%0A%20%20%20%20SERIES_CODE_TO_NAME_MAP%20%3D%20dict(%0A%20%20%20%20%20%20%20%20zip(%0A%20%20%20%20%20%20%20%20%20%20%20%20series_descriptions%5B%22Series%20code%22%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20series_descriptions%5B%22Series%20name%22%5D%2C%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20)%0A%0A%20%20%20%20%23%20Create%20the%20map%20from%20the%20series%20name%20to%20the%20series%20code%0A%20%20%20%20SERIES_NAME_TO_CODE_MAP%20%3D%20dict(%0A%20%20%20%20%20%20%20%20zip(%0A%20%20%20%20%20%20%20%20%20%20%20%20series_descriptions%5B%22Series%20name%22%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20series_descriptions%5B%22Series%20code%22%5D%2C%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20)%0A%20%20%20%20return%20SERIES_CODE_TO_NAME_MAP%2C%20SERIES_NAME_TO_CODE_MAP%0A%0A%0A%40app.cell%0Adef%20_(GREEN_COLOUR%2C%20html%2C%20html_heading%2C%20md)%3A%0A%20%20%20%20%23%20Create%20the%20title%20slide%0A%20%20%20%20html(%0A%20%20%20%20%20%20%20%20md(%22%23%20MA0218%20Mini%20Project%3A%22).center()%2C%0A%20%20%20%20%20%20%20%20html_heading(1%2C%20%22The%20Climate%20Forum%22).center().style(color%3DGREEN_COLOUR)%2C%0A%20%20%20%20%20%20%20%20md(%22By%3A%20Nicholas%2C%20Haziq%2C%20Dylan%20and%20Jun%20Feng%22)%0A%20%20%20%20%20%20%20%20.center()%0A%20%20%20%20%20%20%20%20.style(padding%3D%225em%22)%2C%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(data%2C%20html%2C%20md%2C%20ui_table)%3A%0A%20%20%20%20%23%20The%20slide%20for%20the%20data%20set%20used%0A%20%20%20%20html(%0A%20%20%20%20%20%20%20%20md(%22%23%23%20Data%20set%22)%2C%0A%20%20%20%20%20%20%20%20html(%0A%20%20%20%20%20%20%20%20%20%20%20%20%22%3Cp%3E%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22The%20data%20set%20used%20is%20the%20climate%20change%20data%20set.%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Have%20a%20look%20at%20the%20data%20set%20in%20the%20table%20below%3A%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22%3C%2Fp%3E%22%2C%0A%20%20%20%20%20%20%20%20).style(padding%3D%2210px%200px%22)%2C%0A%20%20%20%20%20%20%20%20ui_table(data)%2C%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(%0A%20%20%20%20GREEN_COLOUR%2C%0A%20%20%20%20PROBLEM_1_QUESTION%2C%0A%20%20%20%20PROBLEM_2_QUESTION%2C%0A%20%20%20%20html%2C%0A%20%20%20%20html_numbered_list%2C%0A%20%20%20%20md%2C%0A%20%20%20%20style_inline%2C%0A)%3A%0A%20%20%20%20%23%20The%20slide%20for%20the%20objectives%0A%20%20%20%20md(%0A%20%20%20%20%20%20%20%20%22%23%23%20Objectives%22%2C%0A%20%20%20%20%20%20%20%20%22%22%2C%0A%20%20%20%20%20%20%20%20%22The%20two%20main%20objectives%20of%20this%20mini%20project%20are%3A%22%2C%0A%20%20%20%20%20%20%20%20%22%22%2C%0A%20%20%20%20%20%20%20%20html_numbered_list(%0A%20%20%20%20%20%20%20%20%20%20%20%20html(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Find%20out%20if%20we%20are%20getting%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20style_inline(%22greener%22%2C%20color%3DGREEN_COLOUR)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22over%20the%20years.%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Determine%20the%20best%20country%20to%20move%20to%20in%20the%20future.%22%2C%0A%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%22These%20objectives%20are%20formulated%20as%202%20problem%20statements%3A%22%2C%0A%20%20%20%20%20%20%20%20html_numbered_list(%0A%20%20%20%20%20%20%20%20%20%20%20%20PROBLEM_1_QUESTION%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20PROBLEM_2_QUESTION%2C%0A%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(%0A%20%20%20%20COLUMNS_TO_DROP%2C%0A%20%20%20%20SERIES_CODES%2C%0A%20%20%20%20YEAR_RANGE_STR%2C%0A%20%20%20%20data%2C%0A%20%20%20%20html%2C%0A%20%20%20%20mo%2C%0A%20%20%20%20np%2C%0A%20%20%20%20pd%2C%0A%20%20%20%20re%2C%0A)%3A%0A%20%20%20%20%23%20Create%20the%20function%20to%20clean%20the%20data%0A%20%20%20%20def%20clean_data(given_data%3A%20pd.DataFrame)%20-%3E%20pd.DataFrame%3A%0A%20%20%20%20%20%20%20%20%22Function%20to%20clean%20up%20the%20data.%22%0A%0A%20%20%20%20%20%20%20%20%23%20Make%20a%20copy%20of%20the%20data%0A%20%20%20%20%20%20%20%20cleaned_data%20%3D%20given_data.copy()%0A%0A%20%20%20%20%20%20%20%20%23%20Convert%20all%20the%20column%20names%20to%20string%0A%20%20%20%20%20%20%20%20cleaned_data.columns%20%3D%20data.columns.astype(str)%0A%0A%20%20%20%20%20%20%20%20%23%20Drop%20the%20columns%20that%20aren't%20needed%0A%20%20%20%20%20%20%20%20cleaned_data.drop(COLUMNS_TO_DROP%2C%20axis%3D1%2C%20inplace%3DTrue)%0A%0A%20%20%20%20%20%20%20%20%23%20Coerce%20all%20the%20data%20in%20the%20columns%20for%20the%20years%20to%20numeric%0A%20%20%20%20%20%20%20%20cleaned_data%5BYEAR_RANGE_STR%5D%20%3D%20cleaned_data%5BYEAR_RANGE_STR%5D.apply(%0A%20%20%20%20%20%20%20%20%20%20%20%20lambda%20elem%3A%20pd.to_numeric(elem%2C%20errors%3D%22coerce%22)%0A%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20%20%20%20%20%23%20Replace%20all%20infinity%20values%20with%20NaNs%0A%20%20%20%20%20%20%20%20cleaned_data%5BYEAR_RANGE_STR%5D%20%3D%20cleaned_data%5BYEAR_RANGE_STR%5D.replace(%0A%20%20%20%20%20%20%20%20%20%20%20%20%5Bnp.inf%2C%20-np.inf%5D%2C%20np.nan%0A%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20%20%20%20%20%23%20Drop%20all%20the%20rows%20in%20the%20years%20that%20have%20all%20their%20values%20as%20NaNs%0A%20%20%20%20%20%20%20%20cleaned_data.drop(%0A%20%20%20%20%20%20%20%20%20%20%20%20cleaned_data%5Bcleaned_data%5BYEAR_RANGE_STR%5D.isna().all(axis%3D1)%5D.index%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20inplace%3DTrue%2C%0A%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20%20%20%20%20%23%20Drop%20all%20the%20rows%20with%20series%20we%20don't%20need%0A%20%20%20%20%20%20%20%20cleaned_data.drop(%0A%20%20%20%20%20%20%20%20%20%20%20%20cleaned_data%5B~cleaned_data%5B%22Series%20code%22%5D.isin(SERIES_CODES)%5D.index%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20inplace%3DTrue%2C%0A%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20%20%20%20%20%23%20Reset%20the%20index%20of%20the%20data%20frame%0A%20%20%20%20%20%20%20%20cleaned_data.reset_index(drop%3DTrue%2C%20inplace%3DTrue)%0A%0A%20%20%20%20%20%20%20%20%23%20Return%20the%20data%0A%20%20%20%20%20%20%20%20return%20cleaned_data%0A%0A%20%20%20%20%23%20Create%20the%20function%20to%20remove%20everything%20after%20a%20line%20of%20code%0A%20%20%20%20def%20strip_unnecessary_code(line_of_code%3A%20str)%20-%3E%20str%3A%0A%20%20%20%20%20%20%20%20return%20re.sub(%0A%20%20%20%20%20%20%20%20%20%20%20%20f%22(%7Bline_of_code%7D).*%3F'%22%2C%20%22%5C%5C1%26quot%3B'%22%2C%20mo.show_code().text%0A%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20%23%20Save%20the%20code%20to%20clean%20the%20data%20for%20later%0A%20%20%20%20clean_data_function_code%20%3D%20html(%0A%20%20%20%20%20%20%20%20strip_unnecessary_code(%22return%20cleaned_data%22)%0A%20%20%20%20)%0A%20%20%20%20return%20clean_data%2C%20clean_data_function_code%2C%20strip_unnecessary_code%0A%0A%0A%40app.cell%0Adef%20_(%0A%20%20%20%20IterativeImputer%2C%0A%20%20%20%20LinearRegression%2C%0A%20%20%20%20PolynomialFeatures%2C%0A%20%20%20%20YEAR_RANGE_STR%2C%0A%20%20%20%20html%2C%0A%20%20%20%20make_pipeline%2C%0A%20%20%20%20pd%2C%0A%20%20%20%20strip_unnecessary_code%2C%0A)%3A%0A%20%20%20%20%23%20Create%20the%20function%20to%20impute%20the%20missing%20data%0A%20%20%20%20def%20impute_missing_data(given_data%3A%20pd.DataFrame)%20-%3E%20pd.DataFrame%3A%0A%20%20%20%20%20%20%20%20%22Function%20to%20impute%20the%20missing%20data%20row%20by%20row.%22%0A%0A%20%20%20%20%20%20%20%20%23%20Initialise%20the%20imputer%20object%0A%20%20%20%20%20%20%20%20imputer_object%20%3D%20IterativeImputer(%0A%20%20%20%20%20%20%20%20%20%20%20%20estimator%3Dmake_pipeline(PolynomialFeatures(3)%2C%20LinearRegression())%0A%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20%20%20%20%20%23%20Make%20a%20copy%20of%20the%20data%0A%20%20%20%20%20%20%20%20imputed_data%20%3D%20given_data.copy()%0A%0A%20%20%20%20%20%20%20%20%23%20Iterate%20over%20the%20given%20data%0A%20%20%20%20%20%20%20%20for%20index%2C%20row%20in%20given_data%5BYEAR_RANGE_STR%5D.iterrows()%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20Impute%20the%20data%20for%20the%20row%0A%20%20%20%20%20%20%20%20%20%20%20%20imputed_row%20%3D%20imputer_object.fit_transform(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20list(zip(YEAR_RANGE_STR%2C%20row))%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20Remove%20the%20year%20from%20the%20imputed%20row%0A%20%20%20%20%20%20%20%20%20%20%20%20imputed_row_data%20%3D%20%5Bvalue%20for%20(_%2C%20value)%20in%20imputed_row%5D%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20Set%20the%20imputed%20row%20data%20to%20the%20imputed%20data%0A%20%20%20%20%20%20%20%20%20%20%20%20imputed_data.loc%5Bindex%2C%20YEAR_RANGE_STR%5D%20%3D%20imputed_row_data%0A%0A%20%20%20%20%20%20%20%20%23%20Return%20the%20imputed%20data%0A%20%20%20%20%20%20%20%20return%20imputed_data%0A%0A%20%20%20%20%23%20Save%20the%20code%20to%20impute%20the%20data%20for%20later%0A%20%20%20%20impute_missing_data_function_code%20%3D%20html(%0A%20%20%20%20%20%20%20%20strip_unnecessary_code(%22return%20imputed_data%22)%0A%20%20%20%20)%0A%20%20%20%20return%20impute_missing_data%2C%20impute_missing_data_function_code%0A%0A%0A%40app.cell%0Adef%20_(clean_data%2C%20data)%3A%0A%20%20%20%20%23%20Clean%20the%20data%0A%20%20%20%20cleaned_data%20%3D%20clean_data(data)%0A%20%20%20%20return%20(cleaned_data%2C)%0A%0A%0A%40app.cell%0Adef%20_(cleaned_data%2C%20impute_missing_data)%3A%0A%20%20%20%20%23%20Impute%20the%20missing%20data%0A%20%20%20%20imputed_data%20%3D%20impute_missing_data(cleaned_data)%0A%20%20%20%20return%20(imputed_data%2C)%0A%0A%0A%40app.cell%0Adef%20_(pd)%3A%0A%20%20%20%20def%20format_data_for_problem(%0A%20%20%20%20%20%20%20%20given_data%3A%20pd.DataFrame%2C%0A%20%20%20%20%20%20%20%20regions%3A%20list%5Bstr%5D%2C%0A%20%20%20%20%20%20%20%20series_codes%3A%20list%5Bstr%5D%2C%0A%20%20%20%20)%20-%3E%20dict%5Bstr%2C%20pd.DataFrame%5D%3A%0A%20%20%20%20%20%20%20%20%22Function%20to%20format%20the%20data%20properly%20for%20the%20problems.%22%0A%0A%20%20%20%20%20%20%20%20%23%20Initialise%20the%20dictionary%20to%20store%20the%20data%20for%20problem%201%0A%20%20%20%20%20%20%20%20formatted_data%20%3D%20%7B%7D%0A%0A%20%20%20%20%20%20%20%20%23%20Iterate%20over%20all%20the%20regions%20required%20for%20problem%201%0A%20%20%20%20%20%20%20%20for%20region%20in%20regions%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20Get%20the%20region%20data%0A%20%20%20%20%20%20%20%20%20%20%20%20region_data%20%3D%20given_data.loc%5Bgiven_data%5B%22Country%20name%22%5D%20%3D%3D%20region%5D%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20Grab%20the%20data%20that%20is%20in%20the%20series%20for%20problem%201%0A%20%20%20%20%20%20%20%20%20%20%20%20region_series_data%20%3D%20(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20region_data.loc%5Bregion_data%5B%22Series%20code%22%5D.isin(series_codes)%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20.drop(columns%3D%5B%22Country%20name%22%2C%20%22Series%20code%22%5D)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20.reset_index(drop%3DTrue)%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20Pivot%20the%20data%20so%20that%20the%20series%20name%20is%20at%20the%20top%0A%20%20%20%20%20%20%20%20%20%20%20%20pivoted_region_data%20%3D%20region_series_data.pivot_table(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20columns%3D%22Series%20name%22%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20Add%20the%20data%20to%20the%20dictionary%0A%20%20%20%20%20%20%20%20%20%20%20%20formatted_data%5Bregion%5D%20%3D%20pivoted_region_data%0A%0A%20%20%20%20%20%20%20%20%23%20Return%20the%20dictionary%20containing%20the%20formatted%20data%0A%20%20%20%20%20%20%20%20return%20formatted_data%0A%20%20%20%20return%20(format_data_for_problem%2C)%0A%0A%0A%40app.cell%0Adef%20_(md)%3A%0A%20%20%20%20md(%22%23%20Exploratory%20Analysis%22).center()%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(html%2C%20md%2C%20md_numbered_list)%3A%0A%20%20%20%20md(%0A%20%20%20%20%20%20%20%20%22%23%23%20Exploratory%20Analysis%3A%20Procedure%22%2C%0A%20%20%20%20%20%20%20%20%22Below%20are%20the%20steps%20we%20followed%20to%20explore%20the%20data%3A%22%2C%0A%20%20%20%20%20%20%20%20md_numbered_list(%0A%20%20%20%20%20%20%20%20%20%20%20%20html(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Run%20through%20the%20data%20in%20Microsoft%20Excel%2C%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22and%20note%20that%20the%20data%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22is%20time%20series%20with%20data%20of%20at%20most%2020%20years.%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20html(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22The%20data%20was%20found%20to%20have%20numerous%20missing%20values%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22across%20most%20series%2C%20and%20since%20the%20data%20is%20time%20series%2C%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22data%20that%20is%20too%20sparse%20is%20unsuitable%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22for%20most%20machine%20learning%20models%20to%20train%20on.%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20html(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Most%20of%20the%20sparse%20data%20is%20discarded%2C%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22as%20they%20are%20unusable.%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20html(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Additionally%2C%20with%20such%20a%20small%20number%20of%20data%20points%2C%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22a%20list%20of%20regression%20models%20was%20collated%20from%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Scikit-Learn%20to%20assess%20the%20ability%20of%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22machine%20learning%20models%20to%20fit%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22the%20data%20properly.%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20html(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Hence%2C%20code%20was%20written%20to%20evaluate%20model%20performance%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22on%20one%20series%20and%20the%20results%20were%20compared.%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(%0A%20%20%20%20BayesianRidge%2C%0A%20%20%20%20DecisionTreeRegressor%2C%0A%20%20%20%20ElasticNet%2C%0A%20%20%20%20ExtraTreesRegressor%2C%0A%20%20%20%20GaussianProcessRegressor%2C%0A%20%20%20%20HuberRegressor%2C%0A%20%20%20%20IsotonicRegression%2C%0A%20%20%20%20KNeighborsRegressor%2C%0A%20%20%20%20Lasso%2C%0A%20%20%20%20LinearRegression%2C%0A%20%20%20%20LinearSVR%2C%0A%20%20%20%20PolynomialFeatures%2C%0A%20%20%20%20RANSACRegressor%2C%0A%20%20%20%20RandomForestRegressor%2C%0A%20%20%20%20Ridge%2C%0A%20%20%20%20SGDRegressor%2C%0A%20%20%20%20SVR%2C%0A%20%20%20%20StrMethodFormatter%2C%0A%20%20%20%20YEAR_RANGE%2C%0A%20%20%20%20YEAR_RANGE_STR%2C%0A%20%20%20%20cleaned_data%2C%0A%20%20%20%20make_pipeline%2C%0A%20%20%20%20mean_squared_error%2C%0A%20%20%20%20np%2C%0A%20%20%20%20pd%2C%0A%20%20%20%20plt%2C%0A%20%20%20%20r2_score%2C%0A)%3A%0A%20%20%20%20def%20exploratory_analysis()%3A%0A%20%20%20%20%20%20%20%20%22Exploratory%20analysis%20of%20machine%20learning%20models%20on%20the%20data%20set.%22%0A%0A%20%20%20%20%20%20%20%20%23%20The%20target%20country%20and%20the%20data%20set%20to%20regress%20over%0A%20%20%20%20%20%20%20%20target_country%20%3D%20%22Singapore%22%0A%0A%20%20%20%20%20%20%20%20%23%20The%20target%20series%20to%20regress%20over%2C%20which%20is%0A%20%20%20%20%20%20%20%20%23%20GDP%20(%24)%0A%20%20%20%20%20%20%20%20target_series%20%3D%20%22NY.GDP.MKTP.CD%22%0A%0A%20%20%20%20%20%20%20%20%23%20Reshape%20the%20years%20to%20make%20it%20usable%20for%20training%0A%20%20%20%20%20%20%20%20x_train%20%3D%20YEAR_RANGE.reshape(-1%2C%201)%0A%0A%20%20%20%20%20%20%20%20%23%20The%20data%20to%20use%0A%20%20%20%20%20%20%20%20data%20%3D%20cleaned_data%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20(cleaned_data%5B%22Country%20name%22%5D%20%3D%3D%20target_country)%0A%20%20%20%20%20%20%20%20%20%20%20%20%26%20(cleaned_data%5B%22Series%20code%22%5D%20%3D%3D%20target_series)%0A%20%20%20%20%20%20%20%20%5D%0A%0A%20%20%20%20%20%20%20%20%23%20The%20number%20of%20plots%20in%20a%20column%0A%20%20%20%20%20%20%20%20number_of_plot_columns%20%3D%205%0A%0A%20%20%20%20%20%20%20%20%23%20The%20training%20data%20for%20the%20series%0A%20%20%20%20%20%20%20%20y_train%20%3D%20data%5BYEAR_RANGE_STR%5D.values.flatten()%0A%0A%20%20%20%20%20%20%20%20%23%20Regression%20models%0A%20%20%20%20%20%20%20%20regression_models%20%3D%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Linear%20Regressor%22%3A%20LinearRegression()%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Ridge%20Regressor%22%3A%20Ridge()%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Lasso%20Regressor%22%3A%20Lasso()%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Bayesian%20Ridge%22%3A%20BayesianRidge()%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Elastic%20Net%22%3A%20ElasticNet()%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Huber%20Regressor%22%3A%20HuberRegressor()%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22RANSAC%20Regressor%22%3A%20RANSACRegressor()%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Random%20Forest%20Regressor%22%3A%20RandomForestRegressor(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20n_estimators%3D100%2C%20random_state%3D42%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Extra%20Trees%20Regressor%22%3A%20ExtraTreesRegressor(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20n_estimators%3D100%2C%20random_state%3D42%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22SVR%20(RBF%20Kernel)%22%3A%20SVR(kernel%3D%22rbf%22)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22SVR%20(Linear%20Kernel)%22%3A%20SVR(kernel%3D%22linear%22)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22SVR%20(Poly%20Kernel)%22%3A%20SVR(kernel%3D%22poly%22)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22SVR%20(Sigmoid%20Kernel)%22%3A%20SVR(kernel%3D%22sigmoid%22)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Linear%20SVR%22%3A%20LinearSVR()%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Stochastic%20Gradient%20Descent%20Regressor%22%3A%20SGDRegressor()%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Gaussian%20Process%20Regressor%22%3A%20GaussianProcessRegressor()%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Isotonic%20Regressor%22%3A%20IsotonicRegression()%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20Decision%20Tree%20Regressors%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Decision%20Tree%20Regressor%20(max%20depth%201)%22%3A%20DecisionTreeRegressor(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20max_depth%3D1%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Decision%20Tree%20Regressor%20(max%20depth%202)%22%3A%20DecisionTreeRegressor(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20max_depth%3D2%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Decision%20Tree%20Regressor%20(max%20depth%203)%22%3A%20DecisionTreeRegressor(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20max_depth%3D3%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Decision%20Tree%20Regressor%20(max%20depth%204)%22%3A%20DecisionTreeRegressor(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20max_depth%3D4%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Decision%20Tree%20Regressor%20(max%20depth%205)%22%3A%20DecisionTreeRegressor(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20max_depth%3D5%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Decision%20Tree%20Regressor%20(max%20depth%206)%22%3A%20DecisionTreeRegressor(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20max_depth%3D6%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Decision%20Tree%20Regressor%20(max%20depth%207)%22%3A%20DecisionTreeRegressor(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20max_depth%3D7%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Decision%20Tree%20Regressor%20(max%20depth%208)%22%3A%20DecisionTreeRegressor(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20max_depth%3D8%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Decision%20Tree%20Regressor%20(max%20depth%209)%22%3A%20DecisionTreeRegressor(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20max_depth%3D9%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Decision%20Tree%20Regressor%20(max%20depth%2010)%22%3A%20DecisionTreeRegressor(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20max_depth%3D10%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20KNN%20Regressors%0A%20%20%20%20%20%20%20%20%20%20%20%20%22KNN%20Regressor%20(1%20neighbour)%22%3A%20KNeighborsRegressor(n_neighbors%3D1)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22KNN%20Regressor%20(2%20neighbours)%22%3A%20KNeighborsRegressor(n_neighbors%3D2)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22KNN%20Regressor%20(3%20neighbours)%22%3A%20KNeighborsRegressor(n_neighbors%3D3)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22KNN%20Regressor%20(4%20neighbours)%22%3A%20KNeighborsRegressor(n_neighbors%3D4)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22KNN%20Regressor%20(5%20neighbours)%22%3A%20KNeighborsRegressor(n_neighbors%3D5)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22KNN%20Regressor%20(6%20neighbours)%22%3A%20KNeighborsRegressor(n_neighbors%3D6)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22KNN%20Regressor%20(7%20neighbours)%22%3A%20KNeighborsRegressor(n_neighbors%3D7)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22KNN%20Regressor%20(8%20neighbours)%22%3A%20KNeighborsRegressor(n_neighbors%3D8)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22KNN%20Regressor%20(9%20neighbours)%22%3A%20KNeighborsRegressor(n_neighbors%3D9)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22KNN%20Regressor%20(10%20neighbours)%22%3A%20KNeighborsRegressor(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20n_neighbors%3D10%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20Linear%20regressor%20with%20polynomial%20features%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Polynomial%20Regressor%20(degree%201)%22%3A%20make_pipeline(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20PolynomialFeatures(1)%2C%20LinearRegression()%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Polynomial%20Regressor%20(degree%202)%22%3A%20make_pipeline(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20PolynomialFeatures(2)%2C%20LinearRegression()%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Polynomial%20Regressor%20(degree%203)%22%3A%20make_pipeline(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20PolynomialFeatures(3)%2C%20LinearRegression()%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Polynomial%20Regressor%20(degree%204)%22%3A%20make_pipeline(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20PolynomialFeatures(4)%2C%20LinearRegression()%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Polynomial%20Regressor%20(degree%205)%22%3A%20make_pipeline(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20PolynomialFeatures(5)%2C%20LinearRegression()%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Polynomial%20Regressor%20(degree%206)%22%3A%20make_pipeline(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20PolynomialFeatures(6)%2C%20LinearRegression()%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Polynomial%20Regressor%20(degree%207)%22%3A%20make_pipeline(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20PolynomialFeatures(7)%2C%20LinearRegression()%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Polynomial%20Regressor%20(degree%208)%22%3A%20make_pipeline(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20PolynomialFeatures(8)%2C%20LinearRegression()%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Polynomial%20Regressor%20(degree%209)%22%3A%20make_pipeline(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20PolynomialFeatures(9)%2C%20LinearRegression()%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Polynomial%20Regressor%20(degree%2010)%22%3A%20make_pipeline(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20PolynomialFeatures(10)%2C%20LinearRegression()%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%7D%0A%0A%20%20%20%20%20%20%20%20%23%20Get%20the%20number%20of%20plot%20rows%0A%20%20%20%20%20%20%20%20number_of_plot_rows%20%3D%20int(%0A%20%20%20%20%20%20%20%20%20%20%20%20np.ceil(len(regression_models)%20%2F%20number_of_plot_columns)%0A%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20%20%20%20%20%23%20Create%20the%20figure%20and%20the%20subplots%0A%20%20%20%20%20%20%20%20figure%2C%20axes%20%3D%20plt.subplots(%0A%20%20%20%20%20%20%20%20%20%20%20%20number_of_plot_rows%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20number_of_plot_columns%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20figsize%3D%5Bnumber_of_plot_rows%20*%20number_of_plot_columns%5D%20*%202%2C%0A%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20%20%20%20%20%23%20Initialise%20the%20results%0A%20%20%20%20%20%20%20%20results%20%3D%20%5B%5D%0A%0A%20%20%20%20%20%20%20%20%23%20Iterate%20over%20the%20regression%20models%0A%20%20%20%20%20%20%20%20for%20index%2C%20(name%2C%20model)%20in%20enumerate(regression_models.items())%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20Fit%20the%20model%20on%20the%20data%0A%20%20%20%20%20%20%20%20%20%20%20%20model.fit(x_train%2C%20y_train)%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20Get%20the%20prediction%20from%20the%20model%0A%20%20%20%20%20%20%20%20%20%20%20%20prediction%20%3D%20model.predict(x_train)%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20Get%20the%20R%20squared%20score%0A%20%20%20%20%20%20%20%20%20%20%20%20r_squared%20%3D%20r2_score(y_train%2C%20prediction)%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20Get%20the%20mean%20squared%20error%20and%20root%20mean%20squared%20error%0A%20%20%20%20%20%20%20%20%20%20%20%20mse%20%3D%20mean_squared_error(y_train%2C%20prediction)%0A%20%20%20%20%20%20%20%20%20%20%20%20rmse%20%3D%20np.sqrt(mse)%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20Append%20metrics%20to%20the%20list%0A%20%20%20%20%20%20%20%20%20%20%20%20results.append(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Model%22%3A%20name%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22R%20squared%20score%22%3A%20r_squared%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22MSE%22%3A%20mse%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22RMSE%22%3A%20rmse%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20Get%20the%20axis%20of%20the%20subplot%0A%20%20%20%20%20%20%20%20%20%20%20%20axis%20%3D%20axes.flat%5Bindex%5D%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20Plot%20the%20data%20and%20the%20prediction%0A%20%20%20%20%20%20%20%20%20%20%20%20axis.plot(x_train%2C%20y_train)%0A%20%20%20%20%20%20%20%20%20%20%20%20axis.plot(x_train%2C%20prediction)%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20Set%20the%20title%20to%20the%20model%0A%20%20%20%20%20%20%20%20%20%20%20%20axis.set_title(name)%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20Use%20integers%20for%20the%20x%20axis%0A%20%20%20%20%20%20%20%20%20%20%20%20axis.xaxis.set_major_formatter(StrMethodFormatter(%22%7Bx%3A%2C.0f%7D%22))%0A%0A%20%20%20%20%20%20%20%20%23%20Put%20the%20data%20into%20a%20data%20frame%0A%20%20%20%20%20%20%20%20results_dataframe%20%3D%20(%0A%20%20%20%20%20%20%20%20%20%20%20%20pd.DataFrame(results)%0A%20%20%20%20%20%20%20%20%20%20%20%20.sort_values(by%3D%22R%20squared%20score%22%2C%20ascending%3DFalse)%0A%20%20%20%20%20%20%20%20%20%20%20%20.reset_index(drop%3DTrue)%0A%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20%20%20%20%20%23%20Return%20the%20results%20dataframe%0A%20%20%20%20%20%20%20%20return%20results_dataframe%2C%20figure%0A%0A%20%20%20%20%23%20Run%20the%20exploratory%20analysis%20and%20save%20the%20table%20and%20figure%0A%20%20%20%20exploratory_analysis_table%2C%20exploratory_analysis_figure%20%3D%20(%0A%20%20%20%20%20%20%20%20exploratory_analysis()%0A%20%20%20%20)%0A%20%20%20%20return%20(%0A%20%20%20%20%20%20%20%20exploratory_analysis%2C%0A%20%20%20%20%20%20%20%20exploratory_analysis_figure%2C%0A%20%20%20%20%20%20%20%20exploratory_analysis_table%2C%0A%20%20%20%20)%0A%0A%0A%40app.cell%0Adef%20_(centred_slide_title%2C%20exploratory_analysis_table%2C%20html%2C%20ui_table)%3A%0A%20%20%20%20%23%20Create%20the%20slide%20for%20the%20table%0A%20%20%20%20html(%0A%20%20%20%20%20%20%20%20centred_slide_title(%22Exploratory%20Analysis%3A%20Tabulated%20Results%22)%2C%0A%20%20%20%20%20%20%20%20ui_table(exploratory_analysis_table)%2C%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(centred_slide_title%2C%20exploratory_analysis_figure%2C%20mo)%3A%0A%20%20%20%20%23%20Create%20the%20slide%20for%20the%20plot%20of%20all%20the%20models%0A%20%20%20%20mo.output.append(%0A%20%20%20%20%20%20%20%20centred_slide_title(%22Exploratory%20Analysis%3A%20Plots%20of%20Regression%20Models%22)%0A%20%20%20%20)%0A%20%20%20%20mo.output.append(exploratory_analysis_figure)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(PROBLEM_1_QUESTION%2C%20html%2C%20html_heading%2C%20md)%3A%0A%20%20%20%20html(%0A%20%20%20%20%20%20%20%20md(%22%23%20Problem%201%3A%22).center()%2C%0A%20%20%20%20%20%20%20%20html_heading(%0A%20%20%20%20%20%20%20%20%20%20%20%201%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20PROBLEM_1_QUESTION%2C%0A%20%20%20%20%20%20%20%20).center()%2C%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(%0A%20%20%20%20REGIONS_FOR_PROBLEM_1%2C%0A%20%20%20%20SERIES_CODES_PROBLEM_1%2C%0A%20%20%20%20format_data_for_problem%2C%0A%20%20%20%20imputed_data%2C%0A)%3A%0A%20%20%20%20%23%20Create%20the%20data%20for%20problem%201%0A%20%20%20%20problem_1_data%20%3D%20format_data_for_problem(%0A%20%20%20%20%20%20%20%20imputed_data%2C%20REGIONS_FOR_PROBLEM_1%2C%20SERIES_CODES_PROBLEM_1%0A%20%20%20%20)%0A%20%20%20%20return%20(problem_1_data%2C)%0A%0A%0A%40app.cell%0Adef%20_(html%2C%20md%2C%20md_numbered_list)%3A%0A%20%20%20%20%23%20Display%20the%20slide%20for%20the%20procedure%20to%20prepare%20the%20data%20for%20problem%201%0A%20%20%20%20html(%0A%20%20%20%20%20%20%20%20md(%0A%20%20%20%20%20%20%20%20%20%20%20%20%22%23%23%20Problem%201%3A%20Data%20preparation%20and%20procedure%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22The%20given%20climate%20change%20data%20is%20a%20bit%20of%20a%20mess%2C%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22so%20the%20data%20is%20prepared%20following%20the%20procedure%20below%3A%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20md_numbered_list(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20html(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Pull%20out%20all%20the%20data%20for%20the%20series%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22that%20are%20relevant%20to%20sustainability.%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22An%20example%20is%20carbon%20dioxide%20emissions.%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20html(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Format%20the%20data%20such%20that%20the%20series%20are%20the%20columns%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22and%20the%20years%20are%20the%20rows.%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20html(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Select%20the%20data%20for%20the%20regions%20that%20we%20are%20interested%20in.%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Once%20the%20data%20has%20been%20prepared%2C%20a%20linear%20regression%20model%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22is%20fitted%20on%20to%20the%20data%20to%20show%20the%20trends%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22and%20the%20graph%20is%20plotted%20using%20Matplotlib%20subplots.%22%2C%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(html%2C%20md%2C%20md_unnumbered_list%2C%20problem_1_data%2C%20ui_table)%3A%0A%20%20%20%20%23%20Display%20the%20prepared%20data%0A%20%20%20%20html(%0A%20%20%20%20%20%20%20%20md(%22%23%23%20Problem%201%3A%20Prepared%20data%22).center()%2C%0A%20%20%20%20%20%20%20%20md_unnumbered_list(%0A%20%20%20%20%20%20%20%20%20%20%20%20*%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20html(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20country_name.title()%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20ui_table(country_data%2C%20selection%3DNone%2C%20page_size%3D5)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20for%20country_name%2C%20country_data%20in%20problem_1_data.items()%0A%20%20%20%20%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(%0A%20%20%20%20LinearRegression%2C%0A%20%20%20%20StrMethodFormatter%2C%0A%20%20%20%20YEAR_RANGE%2C%0A%20%20%20%20np%2C%0A%20%20%20%20plt%2C%0A%20%20%20%20problem_1_data%2C%0A)%3A%0A%20%20%20%20def%20solve_problem_1()%3A%0A%20%20%20%20%20%20%20%20%22Function%20to%20solve%20problem%201.%22%0A%0A%20%20%20%20%20%20%20%20%23%20Initialise%20the%20list%20of%20figures%20and%20axes%0A%20%20%20%20%20%20%20%20all_figures%20%3D%20%5B%5D%0A%0A%20%20%20%20%20%20%20%20%23%20Get%20the%20list%20of%20years%20for%20training%0A%20%20%20%20%20%20%20%20years%20%3D%20YEAR_RANGE.reshape(-1%2C%201)%0A%0A%20%20%20%20%20%20%20%20%23%20Initialise%20the%20model%20to%20show%20the%20trend%0A%20%20%20%20%20%20%20%20model%20%3D%20LinearRegression()%0A%0A%20%20%20%20%20%20%20%20%23%20Create%20the%20sub%20plots%0A%20%20%20%20%20%20%20%20figure%2C%20axes%20%3D%20plt.subplots(%0A%20%20%20%20%20%20%20%20%20%20%20%20len(problem_1_data)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20np.max(%5Blen(data.columns)%20for%20data%20in%20problem_1_data.values()%5D)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20figsize%3D(64%2C%2064)%2C%0A%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20%20%20%20%20%23%20Iterate%20over%20all%20the%20countries%0A%20%20%20%20%20%20%20%20for%20country_index%2C%20(country%2C%20data)%20in%20enumerate(problem_1_data.items())%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20Iterate%20over%20all%20the%20columns%20in%20the%20data%0A%20%20%20%20%20%20%20%20%20%20%20%20for%20column_index%2C%20column%20in%20enumerate(data)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23%20Get%20the%20column%20data%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20column_data%20%3D%20data%5Bcolumn%5D%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23%20Fit%20the%20models%20on%20the%20data%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20model.fit(years%2C%20column_data)%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23%20Predict%20the%20values%20for%20the%20data%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20prediction%20%3D%20model.predict(years)%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23%20Get%20the%20axis%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20axis%20%3D%20axes%5Bcountry_index%2C%20column_index%5D%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23%20Plot%20the%20data%20and%20the%20prediction%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20axis.scatter(years%2C%20column_data)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20axis.plot(years%2C%20column_data)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20axis.plot(years%2C%20prediction)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20axis.set_title(country.title())%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20axis.set_xlabel(%22Year%22)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20axis.set_ylabel(column)%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23%20Set%20the%20x%20axis%20format%20to%20integers%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20axis.xaxis.set_major_formatter(StrMethodFormatter(%22%7Bx%3A%2C.0f%7D%22))%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23%20Add%20the%20figure%20to%20the%20lists%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20all_figures.append(figure)%0A%0A%20%20%20%20%20%20%20%20%23%20Return%20the%20figure%0A%20%20%20%20%20%20%20%20return%20figure%0A%0A%20%20%20%20%23%20Save%20the%20graph%20plots%20for%20problem%201%0A%20%20%20%20problem_1_graph_plots%20%3D%20solve_problem_1()%0A%20%20%20%20return%20problem_1_graph_plots%2C%20solve_problem_1%0A%0A%0A%40app.cell%0Adef%20_(centred_slide_title%2C%20mo%2C%20problem_1_graph_plots)%3A%0A%20%20%20%20%23%20Create%20the%20slide%20to%20display%20the%20graph%20plots%20for%20problem%201%0A%20%20%20%20mo.output.append(centred_slide_title(%22Problem%201%3A%20Trend%20plots%22))%0A%20%20%20%20mo.output.append(problem_1_graph_plots)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(html%2C%20md%2C%20md_numbered_list)%3A%0A%20%20%20%20%23%20Create%20the%20slide%20to%20show%20the%20insights%20for%20problem%201%0A%20%20%20%20md(%0A%20%20%20%20%20%20%20%20%22%23%23%20Problem%201%3A%20Insights%22%2C%0A%20%20%20%20%20%20%20%20%22From%20the%20trend%20plots%20in%20the%20previous%20slide%2C%22%2C%0A%20%20%20%20%20%20%20%20%22we%20have%20gathered%20these%20insights%3A%22%2C%0A%20%20%20%20%20%20%20%20md_numbered_list(%0A%20%20%20%20%20%20%20%20%20%20%20%20html(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22In%20general%2C%20we%20are%20not%20becoming%20greener%20or%20more%20sustainable.%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Globally%2C%20carbon%20dioxide%20emissions%20are%20increasing%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22across%20the%20board%2C%20except%20for%20Europe%20and%20Central%20Asia.%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20html(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Methane%20emissions%20have%20also%20been%20increasing%20across%20the%20board%2C%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22with%20only%20the%20Euro%20area%20and%20the%20small%20islands%20decreasing%20in%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22methane%20emissions.%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20html(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22These%20trends%20are%20expected%2C%20as%20total%20energy%20use%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22has%20increased%20across%20the%20board%2C%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22save%20for%20Europe%20and%20Central%20Asia%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22which%20decreased%20their%20energy%20use.%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20html(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22However%2C%20there%20is%20some%20hope%2C%20as%20we%20are%20generally%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22growing%20in%20an%20increasingly%20sustainable%20manner%2C%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22except%20for%20the%20Middle%20East%20and%20North%20Africa%2C%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22as%20carbon%20dioxide%20emissions%20and%20energy%20use%20per%20unit%20of%20GDP%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22has%20been%20falling.%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(PROBLEM_2_QUESTION%2C%20html%2C%20html_heading%2C%20md)%3A%0A%20%20%20%20%23%20Display%20the%20title%20slide%20for%20problem%202%0A%20%20%20%20html(%0A%20%20%20%20%20%20%20%20md(%22%23%20Problem%202%3A%22).center()%2C%0A%20%20%20%20%20%20%20%20html_heading(1%2C%20PROBLEM_2_QUESTION).center()%2C%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(%0A%20%20%20%20REGIONS_TO_REMOVE_FOR_PROBLEM_2%2C%0A%20%20%20%20SERIES_CODES%2C%0A%20%20%20%20format_data_for_problem%2C%0A%20%20%20%20imputed_data%2C%0A)%3A%0A%20%20%20%20%23%20Create%20the%20data%20for%20problem%202%0A%20%20%20%20problem_2_data%20%3D%20format_data_for_problem(%0A%20%20%20%20%20%20%20%20imputed_data%2C%0A%20%20%20%20%20%20%20%20imputed_data%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20~imputed_data%5B%22Country%20name%22%5D.isin(REGIONS_TO_REMOVE_FOR_PROBLEM_2)%0A%20%20%20%20%20%20%20%20%5D%5B%22Country%20name%22%5D.unique()%2C%0A%20%20%20%20%20%20%20%20SERIES_CODES%2C%0A%20%20%20%20)%0A%20%20%20%20return%20(problem_2_data%2C)%0A%0A%0A%40app.cell%0Adef%20_(html%2C%20md%2C%20md_numbered_list)%3A%0A%20%20%20%20%23%20Create%20the%20slide%20to%20describe%20the%20data%20preparation%0A%20%20%20%20%23%20for%20problem%202%0A%20%20%20%20md(%0A%20%20%20%20%20%20%20%20%22%23%23%20Problem%202%3A%20Data%20preparation%22%2C%0A%20%20%20%20%20%20%20%20%22The%20data%20preparation%20for%20problem%202%20is%20quite%20similar%22%2C%0A%20%20%20%20%20%20%20%20%22to%20that%20of%20problem%201%2C%20and%20the%20steps%20are%3A%22%2C%0A%20%20%20%20%20%20%20%20md_numbered_list(%0A%20%20%20%20%20%20%20%20%20%20%20%20html(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Pull%20out%20all%20the%20data%20for%20the%20series%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22that%20are%20significant%20in%20our%20decision%20to%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22live%20in%20the%20country%20in%20the%20future.%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22An%20example%20is%20access%20to%20improved%20sanitation.%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20html(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Format%20the%20data%20such%20that%20the%20series%20are%20the%20columns%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22and%20the%20years%20are%20the%20rows.%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20html(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Select%20the%20data%20for%20all%20countries%2C%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22leaving%20out%20the%20regions.%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(centred_slide_title%2C%20html%2C%20md_unnumbered_list%2C%20problem_2_data%2C%20ui_table)%3A%0A%20%20%20%20%23%20Show%20the%20prepared%20data%0A%20%20%20%20html(%0A%20%20%20%20%20%20%20%20centred_slide_title(%22Problem%202%3A%20Prepared%20data%22)%2C%0A%20%20%20%20%20%20%20%20md_unnumbered_list(%0A%20%20%20%20%20%20%20%20%20%20%20%20*%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20html(country_name.title()%2C%20ui_table(country_data%2C%20page_size%3D5))%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20for%20(country_name%2C%20country_data)%20in%20list(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20problem_2_data.items()%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20)%5B%3A5%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(html%2C%20md%2C%20md_numbered_list%2C%20md_unnumbered_list)%3A%0A%20%20%20%20%23%20Create%20the%20slide%20to%20show%20the%20procedure%20to%0A%20%20%20%20%23%20get%20the%20quality%20of%20life%20scores%0A%20%20%20%20md(%0A%20%20%20%20%20%20%20%20%22%23%23%20Problem%202%3A%20Procedure%22%2C%0A%20%20%20%20%20%20%20%20%22After%20the%20data%20has%20been%20prepared%2C%22%2C%0A%20%20%20%20%20%20%20%20%22the%20procedure%20below%20is%20followed%20to%20obtain%20a%20score%2C%22%2C%0A%20%20%20%20%20%20%20%20%22which%20we%20call%20the%20quality%20of%20life%20score%2C%22%2C%0A%20%20%20%20%20%20%20%20%22to%20rank%20the%20countries%3A%22%2C%0A%20%20%20%20%20%20%20%20md_numbered_list(%0A%20%20%20%20%20%20%20%20%20%20%20%20html(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22For%20each%20country%2C%20a%20cubic%20regressor%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22(a%20polynomial%20regressor%20of%20degree%203)%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22was%20fitted%20on%20every%20single%20series%2C%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22and%20the%20model%20is%20used%20to%20predict%20the%20value%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22for%202025.%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20md_unnumbered_list(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20html(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22For%20example%2C%20the%20model%20is%20trained%20on%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22the%20series%20for%20GDP%20for%20Singapore%2C%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22and%20the%20model%20is%20used%20to%20predict%20the%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22GDP%20value%20for%20Singapore%20in%202025.%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20html(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22The%20predicted%20values%20for%202025%20for%20each%20country%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22is%20then%20normalised%20using%20z-score%20normalisation%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22so%20that%20the%20data%20for%20each%20series%20for%20all%20countries%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22has%20a%20mean%20of%200%20and%20a%20standard%20deviation%20of%201.%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20md_unnumbered_list(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20html(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22For%20example%2C%20the%20series%20for%20GDP%20for%20all%20countries%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22is%20normalised%20using%20z-score%20normalisation%2C%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22so%20the%20GDP%20values%20for%20all%20countries%20has%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22a%20mean%20value%20of%200%20and%20a%20standard%20deviation%20of%201.%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20html(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22With%20the%20z-score%20normalisation%20in%20place%2C%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22the%20values%20for%20every%20series%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22for%20a%20country%20is%20then%20multiplied%20by%20a%20multiplier%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22and%20then%20added%20together%20to%20create%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22the%20quality%20of%20life%20score.%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20md_unnumbered_list(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20html(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22For%20example%2C%20the%20values%20for%20every%20series%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22for%20Singapore%20is%20multiplied%20by%20a%20multiplier%2C%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22and%20then%20added%20together%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22to%20create%20a%20quality%20of%20life%20score%20for%20Singapore.%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20html(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22This%20multiplier%20represents%20the%20preference%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22for%20a%20certain%20aspect%2C%20so%20this%20multiplier%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22can%20be%20edited%20to%20get%20a%20country%20that%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22maximises%20the%20preferred%20aspects%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22while%20minimising%20the%20undesirable%20aspects.%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(html%2C%20md%2C%20md_unnumbered_list)%3A%0A%20%20%20%20%23%20Create%20the%20slide%20for%20the%20formula.%0A%20%20%20%20md(%0A%20%20%20%20%20%20%20%20%22%23%23%20Problem%202%3A%20Formula%22%2C%0A%20%20%20%20%20%20%20%20%22In%20short%2C%20the%20procedure%20in%20the%20previous%20slide%20can%20be%20expressed%22%2C%0A%20%20%20%20%20%20%20%20%22using%20the%20formula%20below%3A%22%2C%0A%20%20%20%20%20%20%20%20md(%0A%20%20%20%20%20%20%20%20%20%20%20%20r%22%5C%5B%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20r%22QoL%20%3D%20%5Csum_%7Bi%20%3D%201%7D%5E%7BN%7D%20(Z(v_i)%20%5Ccdot%20w_i)%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20r%22%5C%5D%22%2C%0A%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%22Where%3A%22%2C%0A%20%20%20%20%20%20%20%20md_unnumbered_list(%0A%20%20%20%20%20%20%20%20%20%20%20%20r%22%5C(QoL%5C)%20is%20the%20quality%20of%20life%20score.%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20html(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20r%22%5C(N%5C)%20is%20the%20total%20number%20of%20aspects%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22(columns%20in%20the%20prepared%20data).%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20html(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20r%22%5C(Z%5C)%20is%20the%20z-score%20normalisation%20function%2C%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20r%22defined%20as%20%5C(Z%20%3D%20%5Cfrac%7Bx%20-%20%5Cmu%7D%7B%5Csigma%7D%5C)%2C%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20r%22where%20%5C(x%5C)%20is%20the%20value%2C%20%5C(%5Cmu%5C)%20is%20the%20mean%2C%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20r%22and%20%5C(%5Csigma%5C)%20is%20the%20standard%20deviation.%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20html(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20r%22%5C(v%5C)%20is%20the%20value%20of%20the%20aspect%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22(column%20value%20in%20the%20prepared%20data).%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20html(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20r%22%5C(w%5C)%20is%20the%20weight%20assigned%20to%20that%20aspect%20by%20the%20user.%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(%0A%20%20%20%20LinearRegression%2C%0A%20%20%20%20PolynomialFeatures%2C%0A%20%20%20%20YEAR_RANGE%2C%0A%20%20%20%20make_pipeline%2C%0A%20%20%20%20np%2C%0A%20%20%20%20pd%2C%0A%20%20%20%20problem_2_data%2C%0A)%3A%0A%20%20%20%20def%20get_predictions_for_problem_2()%3A%0A%20%20%20%20%20%20%20%20%22Function%20to%20get%20the%20predictions%20for%202025%20for%20problem%202.%22%0A%0A%20%20%20%20%20%20%20%20%23%20Create%20the%20dictionary%20of%20predictions%0A%20%20%20%20%20%20%20%20predictions%20%3D%20%7B%7D%0A%0A%20%20%20%20%20%20%20%20%23%20Initialise%20the%20model%20to%20do%20the%20predictions%0A%20%20%20%20%20%20%20%20model%20%3D%20make_pipeline(PolynomialFeatures(3)%2C%20LinearRegression())%0A%0A%20%20%20%20%20%20%20%20%23%20Fix%20the%20year%20range%20for%20training%0A%20%20%20%20%20%20%20%20years%20%3D%20YEAR_RANGE.reshape(-1%2C%201)%0A%0A%20%20%20%20%20%20%20%20%23%20Iterate%20over%20the%20countries%20in%20the%20problem%202%20data%20set%0A%20%20%20%20%20%20%20%20for%20country%2C%20country_data%20in%20problem_2_data.items()%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20Create%20the%20dictionary%20to%20store%20the%20predictions%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20for%20each%20of%20the%20series%20for%20the%20country%0A%20%20%20%20%20%20%20%20%20%20%20%20country_predictions%20%3D%20%7B%7D%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20Iterate%20over%20the%20series%20in%20the%20country%20data%0A%20%20%20%20%20%20%20%20%20%20%20%20for%20series%2C%20series_data%20in%20country_data.items()%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23%20Fit%20the%20model%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20model.fit(years%2C%20series_data)%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23%20Get%20the%20predicted%20value%20for%202025%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20predicted_value%20%3D%20model.predict(np.array(2025).reshape(-1%2C%201))%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23%20Store%20the%20prediction%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20country_predictions%5Bseries%5D%20%3D%20predicted_value%5B0%5D%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20Append%20the%20country%20predictions%20to%20the%20list%0A%20%20%20%20%20%20%20%20%20%20%20%20predictions%5Bcountry%5D%20%3D%20country_predictions%0A%0A%20%20%20%20%20%20%20%20%23%20Convert%20the%20predictions%20to%20a%20dataframe%0A%20%20%20%20%20%20%20%20predictions_dataframe%20%3D%20pd.DataFrame(predictions)%0A%0A%20%20%20%20%20%20%20%20%23%20Normalise%20the%20predictions%0A%20%20%20%20%20%20%20%20normalised_predictions%20%3D%20(%0A%20%20%20%20%20%20%20%20%20%20%20%20predictions_dataframe%20-%20predictions_dataframe.mean()%0A%20%20%20%20%20%20%20%20)%20%2F%20predictions_dataframe.std()%0A%0A%20%20%20%20%20%20%20%20%23%20Transpose%20the%20predictions%0A%20%20%20%20%20%20%20%20transposed_predictions%20%3D%20normalised_predictions.transpose()%0A%0A%20%20%20%20%20%20%20%20%23%20Fill%20all%20the%20NaNs%20with%20zeros%0A%20%20%20%20%20%20%20%20transposed_predictions.fillna(0%2C%20inplace%3DTrue)%0A%0A%20%20%20%20%20%20%20%20return%20transposed_predictions%2C%20predictions_dataframe.transpose()%0A%0A%20%20%20%20normalised_predictions_problem_2%2C%20raw_predictions_problem_2%20%3D%20(%0A%20%20%20%20%20%20%20%20get_predictions_for_problem_2()%0A%20%20%20%20)%0A%20%20%20%20return%20(%0A%20%20%20%20%20%20%20%20get_predictions_for_problem_2%2C%0A%20%20%20%20%20%20%20%20normalised_predictions_problem_2%2C%0A%20%20%20%20%20%20%20%20raw_predictions_problem_2%2C%0A%20%20%20%20)%0A%0A%0A%40app.cell%0Adef%20_(centred_slide_title%2C%20html%2C%20raw_predictions_problem_2%2C%20ui_table)%3A%0A%20%20%20%20%23%20Show%20the%20raw%20predicted%20values%20for%20problem%202%0A%20%20%20%20html(%0A%20%20%20%20%20%20%20%20centred_slide_title(%22Problem%202%3A%20Raw%20predictions%20for%202025%22)%2C%0A%20%20%20%20%20%20%20%20ui_table(raw_predictions_problem_2)%2C%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(centred_slide_title%2C%20html%2C%20normalised_predictions_problem_2%2C%20ui_table)%3A%0A%20%20%20%20%23%20Show%20the%20normalised%20predicted%20values%20for%20problem%202%0A%20%20%20%20html(%0A%20%20%20%20%20%20%20%20centred_slide_title(%22Problem%202%3A%20Normalised%20predictions%20for%202025%22)%2C%0A%20%20%20%20%20%20%20%20ui_table(normalised_predictions_problem_2)%2C%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(%0A%20%20%20%20SERIES_CODE_TO_MULTIPLIER_MAP%2C%0A%20%20%20%20SERIES_NAME_TO_CODE_MAP%2C%0A%20%20%20%20itemgetter%2C%0A%20%20%20%20mo%2C%0A%20%20%20%20normalised_predictions_problem_2%2C%0A%20%20%20%20pd%2C%0A)%3A%0A%20%20%20%20def%20get_quality_of_life_score_for_problem_2(%0A%20%20%20%20%20%20%20%20series_code_to_multiplier_map%3A%20dict%5Bstr%2C%20mo.ui.slider%5D%2C%0A%20%20%20%20)%3A%0A%20%20%20%20%20%20%20%20%22Function%20to%20get%20the%20quality%20of%20life%20score%20for%20problem%202.%22%0A%0A%20%20%20%20%20%20%20%20%23%20Initialise%20the%20dictionary%20with%20the%20quality%20of%20life%20scores%0A%20%20%20%20%20%20%20%20%23%20for%20each%20country%0A%20%20%20%20%20%20%20%20quality_of_life_scores%20%3D%20%7B%7D%0A%0A%20%20%20%20%20%20%20%20%23%20Get%20the%20list%20of%20series%20codes%20that%20are%20wanted%0A%20%20%20%20%20%20%20%20wanted_series_codes%20%3D%20list(SERIES_CODE_TO_MULTIPLIER_MAP.keys())%0A%0A%20%20%20%20%20%20%20%20%23%20Make%20a%20copy%20of%20the%20normalised%20predictions%0A%20%20%20%20%20%20%20%20normalised_predictions%20%3D%20normalised_predictions_problem_2.copy()%0A%0A%20%20%20%20%20%20%20%20%23%20Convert%20all%20the%20series%20names%20to%20a%20series%20code%0A%20%20%20%20%20%20%20%20normalised_predictions.columns%20%3D%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20SERIES_NAME_TO_CODE_MAP%5Bseries_name%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20for%20series_name%20in%20normalised_predictions.columns%0A%20%20%20%20%20%20%20%20%5D%0A%0A%20%20%20%20%20%20%20%20%23%20Get%20only%20the%20wanted%20series%0A%20%20%20%20%20%20%20%20wanted_predictions%20%3D%20normalised_predictions%5Bwanted_series_codes%5D%0A%0A%20%20%20%20%20%20%20%20%23%20Iterate%20over%20each%20country%0A%20%20%20%20%20%20%20%20for%20country%2C%20country_data%20in%20wanted_predictions.iterrows()%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20Initialise%20the%20quality%20of%20life%20score%0A%20%20%20%20%20%20%20%20%20%20%20%20qol_score%20%3D%200%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20Iterate%20over%20all%20the%20columns%20in%20the%20country%20data%0A%20%20%20%20%20%20%20%20%20%20%20%20for%20index%2C%20value%20in%20enumerate(country_data)%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23%20Get%20the%20series%20code%20for%20the%20column%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20series_code%20%3D%20wanted_predictions.columns%5Bindex%5D%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23%20Get%20the%20multiplier%20object%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20multiplier_object%20%3D%20series_code_to_multiplier_map%5Bseries_code%5D%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23%20If%20the%20multiplier%20object%20is%20an%20integer%20or%20float%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23%20then%20set%20the%20multiplier%20to%20it%20directly%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20isinstance(multiplier_object%2C%20(int%2C%20float))%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20multiplier%20%3D%20multiplier_object%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23%20Otherwise%2C%20the%20multiplier%20object%20is%20a%20slider%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23%20so%20get%20the%20value%20from%20it%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20multiplier%20%3D%20multiplier_object.value%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23%20Multiply%20the%20value%20by%20the%20multiplier%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23%20and%20add%20the%20result%20to%20the%20score%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20qol_score%20%2B%3D%20value%20*%20multiplier%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20Add%20the%20quality%20of%20life%20score%20for%20the%20country%20to%20the%20dictionary%0A%20%20%20%20%20%20%20%20%20%20%20%20quality_of_life_scores%5Bcountry%5D%20%3D%20qol_score%0A%0A%20%20%20%20%20%20%20%20%23%20Sort%20the%20dictionary%20to%20have%20the%20countries%0A%20%20%20%20%20%20%20%20%23%20with%20the%20highest%20scores%20appear%20first%0A%20%20%20%20%20%20%20%20sorted_quality_of_life_scores%20%3D%20dict(%0A%20%20%20%20%20%20%20%20%20%20%20%20sorted(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20quality_of_life_scores.items()%2C%20key%3Ditemgetter(1)%2C%20reverse%3DTrue%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20%20%20%20%20%23%20Get%20the%20data%20frame%20for%20the%20quality%20of%20life%20scores%0A%20%20%20%20%20%20%20%20quality_of_life_scores_data_frame%20%3D%20pd.DataFrame(%0A%20%20%20%20%20%20%20%20%20%20%20%20sorted_quality_of_life_scores%2C%20index%3D%5B%22Quality%20of%20life%20score%22%5D%0A%20%20%20%20%20%20%20%20).transpose()%0A%0A%20%20%20%20%20%20%20%20%23%20Reset%20the%20index%0A%20%20%20%20%20%20%20%20quality_of_life_scores_data_frame.reset_index(%0A%20%20%20%20%20%20%20%20%20%20%20%20drop%3DFalse%2C%20inplace%3DTrue%2C%20names%3D%22Country%22%0A%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20%20%20%20%20%23%20Set%20the%20index%20for%20the%20dataframe%20to%20be%20from%0A%20%20%20%20%20%20%20%20%23%201%20to%20the%20length%20of%20the%20dataframe%0A%20%20%20%20%20%20%20%20quality_of_life_scores_data_frame.index%20%3D%20range(%0A%20%20%20%20%20%20%20%20%20%20%20%201%2C%20len(quality_of_life_scores_data_frame)%20%2B%201%0A%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20%20%20%20%20%23%20Reset%20the%20the%20index%20once%20more%20to%20get%20the%20rankings%0A%20%20%20%20%20%20%20%20%23%20to%20show%20up%20in%20the%20dataframe%0A%20%20%20%20%20%20%20%20quality_of_life_scores_data_frame.reset_index(%0A%20%20%20%20%20%20%20%20%20%20%20%20drop%3DFalse%2C%20inplace%3DTrue%2C%20names%3D%22Rank%22%0A%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20%20%20%20%20%23%20Return%20the%20quality%20of%20life%20score%20data%20frame%0A%20%20%20%20%20%20%20%20return%20quality_of_life_scores_data_frame%0A%20%20%20%20return%20(get_quality_of_life_score_for_problem_2%2C)%0A%0A%0A%40app.cell%0Adef%20_(%0A%20%20%20%20MULTIPLIER_MAX_VALUE%2C%0A%20%20%20%20MULTIPLIER_MIN_VALUE%2C%0A%20%20%20%20SERIES_CODE_TO_MULTIPLIER_MAP%2C%0A%20%20%20%20mo%2C%0A)%3A%0A%20%20%20%20%23%20Create%20the%20dictionary%20of%20sliders%0A%20%20%20%20multiplier_sliders_for_problem_2%20%3D%20mo.ui.dictionary(%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20series_code%3A%20mo.ui.slider(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20start%3DMULTIPLIER_MIN_VALUE%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20stop%3DMULTIPLIER_MAX_VALUE%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20value%3Ddefault_value%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20show_value%3DTrue%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%20%20%20%20%20%20%20%20%20%20%20%20for%20(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20series_code%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20default_value%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%20in%20SERIES_CODE_TO_MULTIPLIER_MAP.items()%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20)%0A%20%20%20%20return%20(multiplier_sliders_for_problem_2%2C)%0A%0A%0A%40app.cell%0Adef%20_(%0A%20%20%20%20SERIES_CODE_TO_MULTIPLIER_MAP%2C%0A%20%20%20%20SERIES_CODE_TO_NAME_MAP%2C%0A%20%20%20%20centred_slide_title%2C%0A%20%20%20%20get_quality_of_life_score_for_problem_2%2C%0A%20%20%20%20html%2C%0A%20%20%20%20multiplier_sliders_for_problem_2%2C%0A%20%20%20%20ui_table%2C%0A)%3A%0A%20%20%20%20def%20quality_of_life_slide(slider_dictionary)%3A%0A%20%20%20%20%20%20%20%20%22Function%20to%20create%20the%20slide%20for%20the%20quality%20of%20life%20scores.%22%0A%0A%20%20%20%20%20%20%20%20%23%20Create%20the%20list%20for%20the%20slider%20segment%0A%20%20%20%20%20%20%20%20slider_segment%20%3D%20%5B%5D%0A%0A%20%20%20%20%20%20%20%20%23%20Iterate%20over%20the%20series%20codes%0A%20%20%20%20%20%20%20%20for%20series_code%20in%20SERIES_CODE_TO_MULTIPLIER_MAP.keys()%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20Get%20the%20slider%20from%20the%20slider%20dictionary%0A%20%20%20%20%20%20%20%20%20%20%20%20slider%20%3D%20slider_dictionary%5Bseries_code%5D%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20Get%20the%20series%20name%20from%20the%20series%20code%0A%20%20%20%20%20%20%20%20%20%20%20%20series_name%20%3D%20SERIES_CODE_TO_NAME_MAP%5Bseries_code%5D%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20Create%20the%20html%20element%0A%20%20%20%20%20%20%20%20%20%20%20%20html_element%20%3D%20html(html(series_name)%2C%20html(slider)).style(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20display%3D%22flex%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20flex_direction%3D%22column%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20align_items%3D%22center%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20justify_content%3D%22center%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20text_align%3D%22center%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20padding%3D%2210px%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20gap%3D%225px%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20box_shadow%3D%220%204px%208px%200%20rgba(0%2C%200%2C%200%2C%200.2)%2C%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%2B%20%220%203px%2010px%200%20rgba(0%2C%200%2C%200%2C%200.19)%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20width%3D%22100%25%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20height%3D%22100%25%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20font_size%3D%2215px%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%23%20Add%20the%20html%20element%20to%20the%20slider%20segment%0A%20%20%20%20%20%20%20%20%20%20%20%20slider_segment.append(html_element)%0A%0A%20%20%20%20%20%20%20%20%23%20Get%20the%20dataframe%20of%20the%20quality%20of%20life%20scores%0A%20%20%20%20%20%20%20%20quality_of_life_scores_data_frame%20%3D%20(%0A%20%20%20%20%20%20%20%20%20%20%20%20get_quality_of_life_score_for_problem_2(slider_dictionary)%0A%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20%20%20%20%20%23%20Create%20the%20html%20for%20the%20slide%0A%20%20%20%20%20%20%20%20return%20html(%0A%20%20%20%20%20%20%20%20%20%20%20%20centred_slide_title(%22Problem%202%3A%20Quality%20of%20life%20scores%22)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20html(*slider_segment).style(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20display%3D%22grid%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20grid_template_columns%3D%22repeat(6%2C%201fr)%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20grid_auto_rows%3D%221fr%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20align_items%3D%22center%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20justify_content%3D%22center%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20gap%3D%2220px%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20padding_bottom%3D%2220px%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20ui_table(quality_of_life_scores_data_frame%2C%20page_size%3D10)%2C%0A%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20%23%20Create%20the%20slide%0A%20%20%20%20quality_of_life_slide(multiplier_sliders_for_problem_2)%0A%20%20%20%20return%20(quality_of_life_slide%2C)%0A%0A%0A%40app.cell%0Adef%20_(md)%3A%0A%20%20%20%20%23%20Create%20the%20title%20slide%20for%20data%20cleaning%0A%20%20%20%20md(%22%23%20Data%20cleaning%20and%20preparation%22).center()%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(md%2C%20md_numbered_list)%3A%0A%20%20%20%20%23%20Create%20the%20slide%20for%20the%20data%20cleaning%0A%20%20%20%20md(%0A%20%20%20%20%20%20%20%20%22%23%23%20Data%20cleaning%22%2C%0A%20%20%20%20%20%20%20%20%22The%20data%20provided%20was%20poorly%20formatted%20and%20organised%22%2C%0A%20%20%20%20%20%20%20%20%22with%20a%20lot%20of%20missing%20values%20across%20all%20columns.%22%2C%0A%20%20%20%20%20%20%20%20%22%22%2C%0A%20%20%20%20%20%20%20%20%22The%20data%20cleaning%20procedure%20we%20used%20are%20as%20follows%3A%22%2C%0A%20%20%20%20%20%20%20%20md_numbered_list(%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Select%20all%20the%20rows%20containing%20the%20series%20that%20we%20have%20chosen.%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Coerce%20all%20the%20data%20to%20be%20numeric.%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Drop%20the%20unnecessary%20columns%2C%20such%20as%20SCALE%20and%20Decimals.%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Drop%20the%20column%20for%202011%2C%20as%20it%20doesn't%20have%20any%20data.%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Drop%20all%20rows%20that%20have%20empty%20values%20in%20the%20year%20columns.%22%2C%0A%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(centred_slide_title%2C%20clean_data_function_code%2C%20html)%3A%0A%20%20%20%20%23%20Show%20the%20code%20for%20cleaning%20the%20data%0A%20%20%20%20html(%0A%20%20%20%20%20%20%20%20centred_slide_title(%22Data%20cleaning%3A%20Implementation%22)%2C%0A%20%20%20%20%20%20%20%20clean_data_function_code%2C%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(html%2C%20md%2C%20md_unnumbered_list)%3A%0A%20%20%20%20%23%20Create%20the%20slide%20for%20data%20imputation%0A%20%20%20%20md(%0A%20%20%20%20%20%20%20%20%22%23%23%20Data%20imputation%3A%20Reasoning%22%2C%0A%20%20%20%20%20%20%20%20md_unnumbered_list(%0A%20%20%20%20%20%20%20%20%20%20%20%20html(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22After%20the%20data%20has%20been%20cleaned%2C%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22the%20numerous%20missing%20values%20need%20to%20be%20filled%20in%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22through%20a%20process%20called%20imputation%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22before%20the%20machine%20learning%20model%20can%20be%20trained%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22on%20the%20data.%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20html(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Using%20the%20results%20of%20the%20exploratory%20analysis%2C%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22we%20picked%20the%20cubic%20regressor%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22(polynomial%20regressor%20of%20degree%203)%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22to%20impute%20the%20missing%20values%20row%20by%20row%2C%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22following%20the%20time%20series.%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Using%20the%20imputer%20on%20the%20entire%20data%20frame%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22created%20ridiculous%20values%20in%20some%20series%2C%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22so%20the%20imputer%20applied%20to%20each%20row%20individually.%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20html(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Linear%20regression%20models%20did%20not%20make%20the%20cut%2C%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22as%20they%20were%20poor%20at%20interpolating%20between%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22the%20values%20in%20the%20data%20set%2C%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22causing%20the%20missing%20values%20to%20not%20match%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22up%20with%20the%20actual%20values.%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20html(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Decision%20tree%20regression%20models%20were%20also%20a%20poor%20choice%2C%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22as%20a%20significant%20amount%20of%20the%20data%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22needed%20to%20be%20extrapolated%20from%20the%20available%20data.%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Decision%20tree%20regression%20models%20were%20good%20at%20interpolating%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22within%20the%20available%20data%2C%20but%20were%20terrible%20at%20extrapolating%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22as%20the%20values%20outside%20of%20the%20available%20data%20were%20just%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22constant%20values%20and%20did%20not%20fit%20the%20time%20series.%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(centred_slide_title%2C%20html%2C%20impute_missing_data_function_code)%3A%0A%20%20%20%20%23%20Create%20the%20slide%20for%20the%20implementation%20the%20imputer%0A%20%20%20%20html(%0A%20%20%20%20%20%20%20%20centred_slide_title(%22Data%20imputation%3A%20Implementation%22)%2C%0A%20%20%20%20%20%20%20%20impute_missing_data_function_code%2C%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(html%2C%20md%2C%20md_unnumbered_list)%3A%0A%20%20%20%20%23%20Create%20the%20slide%20for%20the%20outcome%20and%20conclusion%0A%20%20%20%20md(%0A%20%20%20%20%20%20%20%20%22%23%23%20Outcome%20and%20conclusion%22%2C%0A%20%20%20%20%20%20%20%20md_unnumbered_list(%0A%20%20%20%20%20%20%20%20%20%20%20%20html(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Overall%2C%20we%20have%20managed%20to%20meet%20our%20objectives%20and%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22have%20answered%20our%20problem%20statements%20in%20a%20satisfying%20manner%2C%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22and%20have%20already%20presented%20our%20findings%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22in%20the%20previous%20slides.%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20html(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22We%20have%20found%20that%20the%20time%20series%20data%20that%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22we%20chose%20presented%20quite%20a%20lot%20of%20challenges%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22for%20data%20analysis%20and%20imputation%2C%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22due%20to%20the%20small%20amount%20of%20data%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22for%20machine%20learning%20models%20to%20train%20on.%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20html(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22The%20data%20that%20we%20chose%20gave%20us%20an%20appreciation%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22for%20less%20complex%20models%20like%20linear%20models%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22and%20decision%20trees%2C%20as%20a%20lot%20of%20the%20more%20advanced%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22models%20that%20we%20tried%20to%20use%20did%20not%20fair%20well%20on%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22the%20tiny%20data%20set%20we%20had.%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20html(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Even%20machine%20learning%20models%20that%20usually%20work%20well%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22with%20small%20amounts%20of%20data%2C%20like%20support%20vector%20machines%2C%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22failed%20to%20produce%20good%20results%2C%20and%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22more%20complex%20decision%20trees%20overfitted%20the%20data.%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20html(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22More%20complex%20linear%20models%20that%20have%20regularisation%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22like%20Ridge%20regression%2C%20Elastic-Net%20regression%2C%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22and%20Bayesian%20regression%2C%20also%20failed%20to%20surpass%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22the%20basic%20ordinary%20least%20squares%20linear%20regression%20model%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22in%20performance.%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(html%2C%20md%2C%20md_unnumbered_list)%3A%0A%20%20%20%20%23%20Create%20the%20slide%20for%20the%20out%20of%20course%20content%0A%20%20%20%20md(%0A%20%20%20%20%20%20%20%20%22%23%23%20Out%20of%20course%20content%22%2C%0A%20%20%20%20%20%20%20%20%22The%20out%20of%20course%20content%20that%20we%20explored%20included%20the%20following%3A%22%2C%0A%20%20%20%20%20%20%20%20md_unnumbered_list(%0A%20%20%20%20%20%20%20%20%20%20%20%20html(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22We%20made%20use%20of%20an%20alternative%20to%20Jupyter%20notebooks%2C%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22called%20Marimo%2C%20to%20visualise%20and%20present%20our%20data.%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22This%20entire%20presentation%20is%20created%20in%2C%20and%20presented%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22from%20Marimo.%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22We%20learnt%20about%20the%20various%20Marimo%20UI%20elements%20and%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22how%20to%20use%20them%20to%20create%20the%20interactive%20calculator%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22for%20quality%20of%20life%20scores%20on%20our%20slides.%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22These%20slides%20were%20also%20made%20using%20web%20technologies%2C%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22namely%20HTML%2C%20CSS%20and%20JavaScript%2C%20as%20well%20as%20Markdown%2C%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22which%20we%20had%20to%20learn%20to%20create%20these%20slides.%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20html(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22We%20also%20explored%20data%20imputation%20techniques%2C%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22which%20is%20not%20covered%20in%20the%20course%20at%20all%2C%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22due%20to%20our%20data%20being%20a%20time%20series%20with%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22lots%20of%20missing%20values%2C%20making%20data%20imputation%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22vital%20for%20our%20analysis.%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Improper%20data%20imputation%20could%20result%20in%20vastly%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22different%20results%20and%20conclusions%2C%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22thanks%20to%20our%20data%20set%20having%20so%20much%20missing%20data.%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20html(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22As%20for%20machine%20learning%20models%2C%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22we%20made%20use%20of%20the%20PolynomialFeatures%20preprocessor%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22to%20create%20the%20cubic%20polynomial%20regressor%20that%20we%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22used%20to%20impute%20the%20missing%20values%2C%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22as%20well%20as%20to%20predict%20the%202025%20values%20for%20each%20series.%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Although%20we%20could%20not%20demonstrate%20the%20more%20advanced%20machine%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22learning%20models%20we%20explored%20due%20to%20their%20inefficacies%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22and%20failure%20to%20meet%20our%20needs%20for%20prediction%20and%20imputation%2C%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22we%20realised%20that%20increasing%20model%20complexity%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22does%20not%20necessarily%20improve%20performance%2C%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22and%20on%20such%20a%20tiny%20data%20set%2C%20it%20usually%20reduces%20performance.%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22These%20findings%20are%20part%20of%20our%20exploratory%20analysis.%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20html(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22We%20also%20made%20use%20of%20z-score%20normalisation%2C%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22which%20is%20the%20same%20function%20as%20the%20StandardScaler%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22preprocessor%20found%20in%20Scikit-Learn%2C%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22to%20create%20our%20quality%20of%20life%20score.%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(html%2C%20md%2C%20md_unnumbered_list)%3A%0A%20%20%20%20%23%20Create%20the%20slide%20for%20the%20roles%20and%20responsibilities%0A%20%20%20%20md(%0A%20%20%20%20%20%20%20%20%22%23%23%20Roles%20and%20responsibilities%22%2C%0A%20%20%20%20%20%20%20%20md_unnumbered_list(%0A%20%20%20%20%20%20%20%20%20%20%20%20html(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Haziq%20was%20in%20charge%20of%20the%20exploratory%20analysis%20section%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22and%20looked%20up%20all%20the%20regressors%20in%20Scikit-Learn%20to%20train%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22and%20evaluate%20the%20models'%20performance%20on%20the%20data%20set.%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20html(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Nicholas%20handled%20data%20cleaning%20and%20imputation%2C%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22as%20well%20as%20data%20preparation%20for%20each%20of%20the%20problems%2C%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22making%20use%20of%20Haziq's%20results%20to%20select%20an%20applicable%20imputer%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22to%20be%20used%20to%20fill%20in%20missing%20values.%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20html(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Jun%20Feng%20was%20responsible%20for%20solving%20problem%201%2C%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22making%20use%20of%20the%20imputed%20data%20to%20draw%20regression%20lines%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22to%20show%20the%20trend%2C%20and%20interpreting%20the%20resulting%20trends%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22to%20draw%20our%20conclusions.%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20html(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22Dylan%20was%20in%20charge%20of%20problem%202%2C%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22also%20making%20use%20of%20Haziq's%20results%20to%20determine%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22a%20suitable%20regression%20model%20to%20predict%20a%20value%20for%202025%2C%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22and%20to%20come%20up%20with%20a%20suitable%20algorithm%20to%20turn%20the%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22predicted%20values%20into%20scores%2C%20and%20ranking%20the%20countries%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22based%20on%20those%20scores.%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(html%2C%20html_heading)%3A%0A%20%20%20%20%23%20Create%20the%20thank%20you%20slide%0A%20%20%20%20html(%0A%20%20%20%20%20%20%20%20html_heading(1%2C%20%22Thank%20You!%22)%0A%20%20%20%20%20%20%20%20.center()%0A%20%20%20%20%20%20%20%20.style(%0A%20%20%20%20%20%20%20%20%20%20%20%20background_image%3D%22linear-gradient(to%20right%2C%20violet%2C%20indigo%2C%20blue%2C%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%2B%20%22green%2C%20yellow%2C%20orange%2C%20red)%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20color%3D%22transparent%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20background_clip%3D%22text%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20**%7B%22-webkit-background-clip%22%3A%20%22text%22%7D%2C%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20).style(%0A%20%20%20%20%20%20%20%20display%3D%22flex%22%2C%0A%20%20%20%20%20%20%20%20align_items%3D%22center%22%2C%0A%20%20%20%20%20%20%20%20justify_content%3D%22center%22%2C%0A%20%20%20%20)%0A%20%20%20%20return%0A%0A%0Aif%20__name__%20%3D%3D%20%22__main__%22%3A%0A%20%20%20%20app.run()%0A
d817bda0a662f39ba50ecab689930d0f2c7f1aa673190f9642933a1021f01be2